Merge remote-tracking branch 'origin/master'

赵嘉伟 4 years ago
commit 1471d4672c

@ -7,14 +7,7 @@ package com.foreverwin.mesnac.common.constant;
* @since 2021-05-12
*/
public class CustomFieldConstant {
/**
*
*/
public static final String ITEM_CUSTOM_FIELD_ACCESSORY_TYPE = "ACCESSORY_TYPE";//辅料类型
/**
*
*/
/**
*
@ -26,34 +19,30 @@ public class CustomFieldConstant {
*/
public static final String WORK_CENTER_CUSTOM_FIELD_PROCESS_CONTROL= "PROCESS_CONTROL";//工控程序
/**
*
*/
public static final String BOM_COMPONENT_CUSTOM_FIELD_STEP_ID = "STEP_ID";//步骤
//工厂
public static String SO_FACTORY = "FACTORY";
public static final String SO_FACTORY = "FACTORY";
//工作指令
public static String SO_WORK_ORDER = "WORK_ORDER";
public static final String SO_WORK_ORDER = "WORK_ORDER";
//项目号
public static String SO_ITEM_NUMER = "ITEM_NUMBER";
public static final String SO_ITEM_NUMBER = "ITEM_NUMBER";
//工单类型
public static String SO_SHOP_ORDER_TYPE = "SHOP_ORDER_TYPE";
public static final String SO_SHOP_ORDER_TYPE = "SHOP_ORDER_TYPE";
//产品类型
public static String SO_PRODUCT_CATEGORY = "PRODUCT_CATEGORY";
public static final String SO_PRODUCT_CATEGORY = "PRODUCT_CATEGORY";
//工单备注
public static String SO_COMMENTS = "COMMENTS";
public static final String SO_COMMENTS = "COMMENTS";
//是否开始生产
public static String SO_START_PRODUCT = "START_PRODUCT";
public static final String SO_START_PRODUCT = "START_PRODUCT";
//**************************************************************************************
public static String ROUTER_OP_PROD_TIME = "PROD_TIME";
public static String ROUTER_OP_OUT_SOURCE = "OUT_SOURCE";
public static final String ROUTER_OP_PROD_TIME = "PROD_TIME";
public static final String ROUTER_OP_OUT_SOURCE = "OUT_SOURCE";
//**************************************************************************************
public static String BOM_COM_STEP_ID = "STEP_ID";
public static final String BOM_COM_STEP_ID = "STEP_ID";
public static final String SFC_DATA_LOCATION = "LOCATION";
}

@ -0,0 +1,42 @@
package com.foreverwin.mesnac.common.controller;
import com.foreverwin.mesnac.common.enums.HandleEnum;
import com.foreverwin.mesnac.common.model.MobileWorkStationData;
import com.foreverwin.mesnac.common.service.MobileWorkStationService;
import com.foreverwin.modular.core.util.CommonMethods;
import com.foreverwin.modular.core.util.R;
import org.springframework.beans.factory.annotation.Autowired;
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;
/**
*
* @author Syngna
* @since 2020-01-04
*/
@RestController
@RequestMapping("/mobileWorkStations")
public class MobileWorkStationController {
@Autowired
public MobileWorkStationService mobileWorkStationService;
@GetMapping("listMobileWorkStationApplication")
public R listMobileWorkStationApplication(String workStation) {
List<MobileWorkStationData> result;
try {
String site = CommonMethods.getSite();
String user = CommonMethods.getUser();
String userBo = HandleEnum.USER.getHandle(site, user);
result = mobileWorkStationService.listMobileWorkStationApplication(site, userBo, workStation);
}
catch (Exception e) {
return R.failed(e.getMessage());
}
return R.ok(result);
}
}

@ -14,6 +14,9 @@ public enum HandleEnum {
/**车间作业控制*/
SFC( "SFCBO:", "SFCBO:{0},{1}" ),
/**用户**/
USER("UserBO:", "UserBO:{0},{1}"),
/**物料清单**/
BOM("BOMBO:","BOMBO:{0},{1},{2},{3}"),
@ -23,6 +26,8 @@ public enum HandleEnum {
/**车间作业控制*/
SFC_BOM( "SFCBOMBO:", "SFCBOMBO:{0}" ),
SFC_DATA( "SFCDataBO:", "SFCDataBO:{0},{1}" ),
/**物料*/
ITEM( "ItemBO:", "ItemBO:{0},{1},{2}" ),

@ -0,0 +1,16 @@
package com.foreverwin.mesnac.common.mapper;
import com.foreverwin.mesnac.common.model.ActivityOption;
import com.foreverwin.mesnac.common.model.MobileWorkStationData;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface MobileWorkStationMapper {
List<ActivityOption> selectActivityOptionList(@Param("activityBoList") List<String> activityBoList);
List<MobileWorkStationData> selectMobileWorkStationList(@Param("site") String site, @Param("userBo") String userBo, @Param("workStation") String workStation);
}

@ -0,0 +1,34 @@
package com.foreverwin.mesnac.common.model;
public class ActivityOption {
private String activity;
private String key;
private String value;
public String getActivity() {
return activity;
}
public void setActivity(String activity) {
this.activity = activity;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

@ -0,0 +1,156 @@
package com.foreverwin.mesnac.common.model;
import java.util.List;
public class MobileWorkStationData {
private String workStationBo;
private String canChangeOperation;
private String canChangeResource;
private String defaultOperationBo;
private String defaultResourceBo;
private String mainInputPrompt;
private String sequence;
private String buttonId;
private String buttonSize;
private String label;
private String imageIcon;
private String activityBo;
private String activity;
private String classOrProgram;
private List<ActivityOption> activityOptionList;
public String getWorkStationBo() {
return workStationBo;
}
public void setWorkStationBo(String workStationBo) {
this.workStationBo = workStationBo;
}
public String getCanChangeOperation() {
return canChangeOperation;
}
public void setCanChangeOperation(String canChangeOperation) {
this.canChangeOperation = canChangeOperation;
}
public String getCanChangeResource() {
return canChangeResource;
}
public void setCanChangeResource(String canChangeResource) {
this.canChangeResource = canChangeResource;
}
public String getDefaultOperationBo() {
return defaultOperationBo;
}
public void setDefaultOperationBo(String defaultOperationBo) {
this.defaultOperationBo = defaultOperationBo;
}
public String getDefaultResourceBo() {
return defaultResourceBo;
}
public void setDefaultResourceBo(String defaultResourceBo) {
this.defaultResourceBo = defaultResourceBo;
}
public String getMainInputPrompt() {
return mainInputPrompt;
}
public void setMainInputPrompt(String mainInputPrompt) {
this.mainInputPrompt = mainInputPrompt;
}
public String getSequence() {
return sequence;
}
public void setSequence(String sequence) {
this.sequence = sequence;
}
public String getButtonId() {
return buttonId;
}
public void setButtonId(String buttonId) {
this.buttonId = buttonId;
}
public String getButtonSize() {
return buttonSize;
}
public void setButtonSize(String buttonSize) {
this.buttonSize = buttonSize;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getImageIcon() {
return imageIcon;
}
public void setImageIcon(String imageIcon) {
this.imageIcon = imageIcon;
}
public String getActivityBo() {
return activityBo;
}
public void setActivityBo(String activityBo) {
this.activityBo = activityBo;
}
public String getActivity() {
return activity;
}
public void setActivity(String activity) {
this.activity = activity;
}
public String getClassOrProgram() {
return classOrProgram;
}
public void setClassOrProgram(String classOrProgram) {
this.classOrProgram = classOrProgram;
}
public List<ActivityOption> getActivityOptionList() {
return activityOptionList;
}
public void setActivityOptionList(List<ActivityOption> activityOptionList) {
this.activityOptionList = activityOptionList;
}
}

@ -0,0 +1,20 @@
package com.foreverwin.mesnac.common.service;
import com.foreverwin.mesnac.common.model.MobileWorkStationData;
import java.util.List;
/**
* <p>
*
* </p>
*
* @author Syngna
* @since 2019-05-30
*/
public interface MobileWorkStationService {
List<MobileWorkStationData> listMobileWorkStationApplication(String site, String userBo, String workStation);
}

@ -0,0 +1,48 @@
package com.foreverwin.mesnac.common.service.impl;
import com.foreverwin.mesnac.common.mapper.MobileWorkStationMapper;
import com.foreverwin.mesnac.common.model.ActivityOption;
import com.foreverwin.mesnac.common.model.MobileWorkStationData;
import com.foreverwin.mesnac.common.service.MobileWorkStationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* <p>
*
* </p>
*
* @author Syngna
* @since 2020-01-04
*/
@Service
public class MobileWorkStationServiceImpl implements MobileWorkStationService {
@Autowired
private MobileWorkStationMapper mobileWorkStationMapper;
@Override
public List<MobileWorkStationData> listMobileWorkStationApplication(String site, String userBo, String workStation) {
List<MobileWorkStationData> workStationDataList = mobileWorkStationMapper.selectMobileWorkStationList(site, userBo, workStation);
if(workStationDataList == null || workStationDataList.size() == 0) {
return new ArrayList<>();
}
List<String> activityList = workStationDataList.stream().map(MobileWorkStationData::getActivityBo).collect(Collectors.toList());
List<ActivityOption> activityOptionList = mobileWorkStationMapper.selectActivityOptionList(activityList);
for(MobileWorkStationData mobileWorkStationData : workStationDataList) {
if(mobileWorkStationData.getActivityOptionList() == null) {
mobileWorkStationData.setActivityOptionList(new ArrayList<>());
}
for(ActivityOption activityOption: activityOptionList) {
if(activityOption.getActivity().equals(mobileWorkStationData.getActivity())) {
mobileWorkStationData.getActivityOptionList().add(activityOption);
}
}
}
return workStationDataList;
}
}

@ -2,6 +2,7 @@ package com.foreverwin.mesnac.common.util;
import com.foreverwin.mesnac.common.model.ExcelColumn;
import com.foreverwin.modular.core.exception.BusinessException;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.CharUtils;
import org.apache.commons.lang.StringUtils;
@ -40,12 +41,17 @@ public class ExcelUtils {
private final static String EXCEL2003 = "xls";
private final static String EXCEL2007 = "xlsx";
public static <T> List<T> readExcel(String fileType, Class<T> tClass, MultipartFile multipartFile){
public static <T> List<T> readExcel(String fileType, Class<T> tClass, MultipartFile multipartFile, FileItem fileItem){
Workbook workbook = null;
List<T> dataList = new ArrayList<>();
try {
InputStream inputStream = multipartFile.getInputStream();
InputStream inputStream = null;
if (multipartFile != null && !multipartFile.isEmpty()) {
inputStream = multipartFile.getInputStream();
} else {
inputStream = fileItem.getInputStream();
}
//分析文件格式
if (EXCEL2003.equals(fileType)) {

@ -0,0 +1,56 @@
<?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.foreverwin.mesnac.common.mapper.MobileWorkStationMapper">
<resultMap id="BaseResultMap" type="com.foreverwin.mesnac.common.model.MobileWorkStationData">
<result column="WORKSTATION_BO" property="workStationBo" />
<result column="CAN_CHANGE_OPERATION" property="canChangeOperation" />
<result column="CAN_CHANGE_RESOURCE" property="canChangeResource" />
<result column="DEFAULT_OPERATION_BO" property="defaultOperationBo" />
<result column="DEFAULT_RESOURCE_BO" property="defaultResourceBo" />
<result column="MAIN_INPUT_PROMPT" property="mainInputPrompt" />
<result column="SEQUENCE" property="sequence" />
<result column="BUTTON_ID" property="buttonId" />
<result column="BUTTON_SIZE" property="buttonSize" />
<result column="LABEL" property="label" />
<result column="IMAGE_ICON" property="imageIcon" />
<result column="ACTIVITY_BO" property="activityBo" />
<result column="ACTIVITY" property="activity" />
<result column="CLASS_OR_PROGRAM" property="classOrProgram" />
</resultMap>
<resultMap id="ActivityOptionMap" type="com.foreverwin.mesnac.common.model.ActivityOption">
<result column="ACTIVITY" property="activity" />
<result column="KEY" property="key" />
<result column="VALUE" property="value" />
</resultMap>
<select id="selectActivityOptionList" resultMap="ActivityOptionMap">
SELECT AC.ACTIVITY, AO.EXEC_UNIT_OPTION AS KEY, SETTING AS VALUE
FROM ACTIVITY_OPTION AO
INNER JOIN ACTIVITY AC ON AC.HANDLE = AO.ACTIVITY_BO
WHERE AC.HANDLE IN
<foreach collection="activityBoList" item="item" separator="," close=")" open="(">
#{item}
</foreach>
</select>
<select id="selectMobileWorkStationList" resultMap="BaseResultMap">
SELECT PC.WORKSTATION_BO, PC.CAN_CHANGE_OPERATION, PC.CAN_CHANGE_RESOURCE, PC.DEFAULT_OPERATION_BO, PC.DEFAULT_RESOURCE_BO, PC.MAIN_INPUT_PROMPT,
PB.SEQUENCE, PB.BUTTON_ID, PB.BUTTON_SIZE, PB.LABEL, PB.IMAGE_ICON, PA.ACTIVITY_BO, AC.ACTIVITY, AC.CLASS_OR_PROGRAM
FROM WORKSTATION WC
INNER JOIN POD_CONFIG PC ON WC.HANDLE = PC.WORKSTATION_BO
INNER JOIN POD_BUTTON PB ON PB.POD_CONFIG_BO = PC.HANDLE
INNER JOIN POD_ACTIVITY PA ON PA.POD_BUTTON_BO = PB.HANDLE
INNER JOIN ACTIVITY AC ON AC.HANDLE = PA.ACTIVITY_BO AND AC.ENABLED = 'true'
INNER JOIN(
SELECT AP.ACTIVITY_OR_GROUP_GBO AS ACTIVITY_BO
FROM USER_GROUP_MEMBER UGM
INNER JOIN ACTIVITY_PERM AP ON UGM.USER_GROUP_BO = AP.USER_OR_GROUP_GBO
WHERE UGM.USER_OR_GROUP_GBO = #{userBo}
GROUP BY AP.ACTIVITY_OR_GROUP_GBO
)AP ON AP.ACTIVITY_BO = PA.ACTIVITY_BO
WHERE WC.SITE = #{site}
AND WC.WORKSTATION = #{workStation}
AND WC.WORKSTATION_TYPE = 'C'
</select>
</mapper>

@ -17,11 +17,13 @@ import com.foreverwin.mesnac.dispatch.service.UserResourceService;
import com.foreverwin.mesnac.meapi.service.ResrceService;
import com.foreverwin.mesnac.meapi.util.StringUtils;
import com.foreverwin.modular.core.exception.BusinessException;
import org.apache.commons.fileupload.FileItem;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.InputStream;
import java.time.LocalDateTime;
@ -38,7 +40,7 @@ import java.util.stream.Collectors;
* @author Leon.L
* @since 2021-06-02
*/
@Service
@Service("sfcDispatchService")
@Transactional(rollbackFor = Exception.class)
public class SfcDispatchServiceImpl extends ServiceImpl<SfcDispatchMapper, SfcDispatch> implements SfcDispatchService {
@ -173,7 +175,7 @@ public class SfcDispatchServiceImpl extends ServiceImpl<SfcDispatchMapper, SfcDi
InputStream inputStream = null;
List<SfcDispatchDto> sfcDispatchList;
try {
sfcDispatchList = ExcelUtils.readExcel(fileType, SfcDispatchDto.class, multipartFile);
sfcDispatchList = ExcelUtils.readExcel(fileType, SfcDispatchDto.class, multipartFile, null);
} finally {
if (inputStream != null){
try {
@ -190,6 +192,36 @@ public class SfcDispatchServiceImpl extends ServiceImpl<SfcDispatchMapper, SfcDi
return this.sfcDispatch(site, user, DispatchStatusEnum.IMPORT.getCode(), message, sfcDispatchList);
}
public String importDispatch(FileItem fileItem, HttpServletRequest httpServletRequest) {
String site = httpServletRequest.getParameter("site");
String user = httpServletRequest.getParameter("user");
String fileType = httpServletRequest.getParameter("fileType");
InputStream inputStream = null;
List<SfcDispatchDto> sfcDispatchList;
try {
sfcDispatchList = ExcelUtils.readExcel(fileType, SfcDispatchDto.class, null, fileItem);
} finally {
if (inputStream != null){
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
if (sfcDispatchList == null || sfcDispatchList.size() <= 0) {
throw BusinessException.build("上传的Excel没有数据或者数据格式不正确");
}
//调用业务处理逻辑
StringBuffer message = new StringBuffer();
this.sfcDispatch(site, user, DispatchStatusEnum.IMPORT.getCode(), message, sfcDispatchList);
return message.toString();
}
/**
@ -264,14 +296,8 @@ public class SfcDispatchServiceImpl extends ServiceImpl<SfcDispatchMapper, SfcDi
}
resourceType = sfcDispatchModel.getResourceType();
//资源、计划时间必输
if (StringUtils.isBlank(resource) || sfcDispatchDto.getPlannedStartDate() == null || sfcDispatchDto.getPlannedCompDate() == null) {
flag = false;
message.append(seq++%3 == 0 ? "\n" : "| |");
message.append("派工单[" + dispatchNo + "]的资源、计划开始或完成时间没维护,不允许发布");
continue;
}
type = sfcDispatch.getDispatchStatus();
sfcDispatch.setHandle(handle);
//是否导入
sfcDispatch.setIsImport(Constants.BOOL_TRUE);

@ -33,9 +33,9 @@ public class GeneratorApplication {
dataSourceConfig.setTypeConvert( new OracleTypeConvert() );
MpGenerator mpGenerator = mpGeneratorBuilder.dataSourceConfig(dataSourceConfig)
.tablePrefix( "APS_", "DS_", "Z_" )
.packageName( "com.foreverwin.mesnac.equip" )
.tables("Z_RESOURCE_INSPECT_PLAN","Z_RESOURCE_INSPECT_RESOURCE","Z_RESOURCE_INSPECT_TASK","Z_RESOURCE_INSPECT_TASK_PARAM")
.author("pavel.Liu")
.packageName( "com.foreverwin.mesnac.meapi" )
.tables("SFC_DATA")
.author("Leon.L")
.uiAppId("com.foreverwin.me")
.uiPackage("com.foreverwin.me.migration")
.build();

@ -463,7 +463,7 @@ public class InterfaceServiceImpl implements InterfaceService {
if (StringUtil.notBlank(shopOrderSyncRequest.getITEM_NUMBER())) {
customFields = new CustomFields();
customFields.setHandle(shopOrderBo);
customFields.setAttribute(CustomFieldConstant.SO_ITEM_NUMER);
customFields.setAttribute(CustomFieldConstant.SO_ITEM_NUMBER);
customFields.setValue(shopOrderSyncRequest.getITEM_NUMBER());
customFieldsList.add(customFields);
}

@ -1,12 +1,15 @@
package com.foreverwin.mesnac.meapi.controller;
import com.foreverwin.mesnac.meapi.dto.SfcDto;
import com.foreverwin.mesnac.meapi.util.StringUtils;
import com.foreverwin.modular.core.exception.BusinessException;
import com.foreverwin.modular.core.util.R;
import com.foreverwin.modular.core.util.FrontPage;
import com.foreverwin.modular.core.util.CommonMethods;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.foreverwin.mesnac.meapi.model.Sfc;
import com.foreverwin.mesnac.meapi.service.SfcService;
import com.foreverwin.modular.core.util.CommonMethods;
import com.foreverwin.modular.core.util.FrontPage;
import com.foreverwin.modular.core.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -25,6 +28,24 @@ public class SfcController {
public SfcService sfcService;
@ResponseBody
@GetMapping("/findSfcData")
public R findSfcData(String sfc) {
SfcDto sfcDto = null;
try {
if (StringUtils.isBlank(sfc)) {
throw BusinessException.build("SFC不能为空");
}
String site = CommonMethods.getSite();
sfcDto = sfcService.findSfcData(site, sfc);
} catch (Exception e) {
return R.failed(e.getMessage());
}
return R.ok(sfcDto);
}
/**
*

@ -3,9 +3,48 @@ package com.foreverwin.mesnac.meapi.dto;
import com.foreverwin.mesnac.meapi.model.Sfc;
public class SfcDto extends Sfc {
String resrce;
String operation;
private String shopOrder;
private String status;
private String item;
private String itemDescription;
private String operation;
private String operationDescription;
private String prepositionOperation;
private String resrce;
private String workCenter;
public String getShopOrder() {
return shopOrder;
}
public void setShopOrder(String shopOrder) {
this.shopOrder = shopOrder;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getItem() {
return item;
}
public void setItem(String item) {
this.item = item;
}
public String getItemDescription() {
return itemDescription;
}
public void setItemDescription(String itemDescription) {
this.itemDescription = itemDescription;
}
public String getOperation() {
return operation;
@ -15,6 +54,22 @@ public class SfcDto extends Sfc {
this.operation = operation;
}
public String getOperationDescription() {
return operationDescription;
}
public void setOperationDescription(String operationDescription) {
this.operationDescription = operationDescription;
}
public String getPrepositionOperation() {
return prepositionOperation;
}
public void setPrepositionOperation(String prepositionOperation) {
this.prepositionOperation = prepositionOperation;
}
public String getResrce() {
return resrce;
}
@ -22,4 +77,12 @@ public class SfcDto extends Sfc {
public void setResrce(String resrce) {
this.resrce = resrce;
}
public String getWorkCenter() {
return workCenter;
}
public void setWorkCenter(String workCenter) {
this.workCenter = workCenter;
}
}

@ -1,7 +1,8 @@
package com.foreverwin.mesnac.meapi.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.foreverwin.mesnac.meapi.dto.SfcDto;
import com.foreverwin.mesnac.meapi.model.Sfc;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@ -22,5 +23,7 @@ public interface SfcMapper extends BaseMapper<Sfc> {
*/
List<Sfc> getSfcListByResrceBO(String resrceBO);
SfcDto findSfcData(@Param("site") String site, @Param("sfc") String sfc);
Sfc findBySfc(@Param("sfc") Sfc sfc);
}

@ -1,6 +1,8 @@
package com.foreverwin.mesnac.meapi.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.foreverwin.mesnac.meapi.dto.SfcDto;
import com.foreverwin.mesnac.meapi.model.Sfc;
import com.baomidou.mybatisplus.extension.service.IService;
import com.foreverwin.mesnac.meapi.model.Sfc;
import com.foreverwin.modular.core.util.FrontPage;
@ -38,4 +40,12 @@ public interface SfcService extends IService<Sfc> {
Sfc findBySfc(Sfc sfc);
/**
*
*
* @param site
* @param sfc
* @return
*/
SfcDto findSfcData(String site, String sfc);
}

@ -1,12 +1,13 @@
package com.foreverwin.mesnac.meapi.service.impl;
import com.foreverwin.mesnac.meapi.dto.SfcDto;
import com.foreverwin.modular.core.util.FrontPage;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.foreverwin.mesnac.meapi.mapper.SfcMapper;
import com.foreverwin.mesnac.meapi.model.Sfc;
import com.foreverwin.mesnac.meapi.service.SfcService;
import com.foreverwin.modular.core.util.FrontPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -62,5 +63,8 @@ public class SfcServiceImpl extends ServiceImpl<SfcMapper, Sfc> implements SfcSe
return sfcMapper.findBySfc(sfc);
}
@Override
public SfcDto findSfcData(String site, String sfc) {
return sfcMapper.findSfcData(site, sfc);
}
}

@ -599,7 +599,7 @@
<!-- BaseMapper标准查询/修改/删除 -->
<select id="selectOperationBySfcBo" resultMap="BaseResultMap">
SELECT OP.HANDLE, OP.OPERATION,OT.DESCRIPTION FROM SFC_ROUTING SR
JOIN SFC_ROUTER SR2 ON SR.HANDLE =SR2.SFC_ROUTING_BO
JOIN SFC_ROUTER SR2 ON SR.HANDLE =SR2.SFC_ROUTING_BO AND SR2.IN_USE = 'true'
JOIN SFC_STEP SS ON SR2.HANDLE =SS.SFC_ROUTER_BO
JOIN OPERATION OP ON 'OperationBO:'|| OP.SITE ||','|| OP.OPERATION||',#'=SS.OPERATION_BO
LEFT JOIN OPERATION_T OT ON OP.HANDLE = OT.OPERATION_BO AND OT.LOCALE = #{locale}

@ -35,6 +35,16 @@
<result column="PARTITION_DATE" property="partitionDate" />
</resultMap>
<resultMap id="FullResultMap" type="com.foreverwin.mesnac.meapi.dto.SfcDto">
<result column="SHOP_ORDER" property="shopOrder" />
<result column="STATUS" property="status" />
<result column="ITEM" property="item" />
<result column="ITEM_DESCRIPTION" property="itemDescription" />
<result column="OPERATION" property="operation" />
<result column="OPERATION_DESCRIPTION" property="operationDescription" />
<result column="PREPOSITION_OPERATION" property="prepositionOperation" />
<result column="RESRCE" property="resrce" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
HANDLE, CHANGE_STAMP, SITE, SFC, STATUS_BO, SHOP_ORDER_BO, QTY, QTY_DONE, QTY_SCRAPPED, QTY_HISTORICAL_MIN, QTY_HISTORICAL_MAX, ITEM_BO, PRIORITY, LOCATION, RMA_MAX_TIMES_PROCESSED, LCC_BO, ORIGINAL_STATUS_BO, QTY_MULT_PERFORMED, ACTUAL_COMP_DATE, PREV_SITE, ORIGINAL_TRANSFER_KEY, IMMEDIATE_ARCHIVE, TRANSFER_DATETIME, TRANSFER_USER, SN_DONE, AIN_EQUIPMENT_ID, CREATED_DATE_TIME, MODIFIED_DATE_TIME, PARTITION_DATE
@ -634,6 +644,7 @@
WHERE RES.HANDLE = #{resrceBO}
ORDER BY IW.DATE_STARTED DESC
</select>
<select id="findBySfc" resultType="com.foreverwin.mesnac.meapi.model.Sfc">
SELECT <include refid="Base_Column_List"></include>
FROM SFC
@ -655,5 +666,20 @@
</where>
</select>
<select id="findSfcData" resultMap="FullResultMap">
SELECT SC.SITE, SC.SFC, SO.SHOP_ORDER, SC.QTY, SC.QTY_DONE, ST.STATUS, IM.ITEM, IT.DESCRIPTION ITEM_DESCRIPTION, OP.OPERATION, OT.DESCRIPTION OPERATION_DESCRIPTION, OTT.DESCRIPTION PREPOSITION_OPERATION
FROM SFC SC
INNER JOIN SHOP_ORDER SO ON SO.HANDLE = SC.SHOP_ORDER_BO
INNER JOIN STATUS ST ON ST.HANDLE = SC.STATUS_BO AND ST.STATUS_GROUP = 'SFC'
INNER JOIN ITEM IM ON IM.HANDLE = SC.ITEM_BO
LEFT JOIN ITEM_T IT ON IT.ITEM_BO = IM.HANDLE AND IT.LOCALE = 'zh'
INNER JOIN SFC_ROUTING SG ON SG.SFC_BO = SC.HANDLE
INNER JOIN SFC_ROUTER SR ON SR.SFC_ROUTING_BO = SG.HANDLE AND SR.IN_USE = 'true'
INNER JOIN SFC_STEP SP ON SP.SFC_ROUTER_BO = SR.HANDLE
INNER JOIN OPERATION OP ON SP.OPERATION_BO = 'OperationBO:'||OP.SITE||','||OP.OPERATION||',#' AND OP.CURRENT_REVISION = 'true'
LEFT JOIN OPERATION_T OT ON OT.OPERATION_BO = OP.HANDLE AND OT.LOCALE = 'zh'
LEFT JOIN Z_SFC_DISPATCH ZSD ON ZSD.SITE = SC.SITE AND ZSD.SFC = SC.SFC AND ZSD.OPERATION = OP.OPERATION AND ZSD.STEP_ID = SP.STEP_ID
LEFT JOIN OPERATION_T OTT ON SPLIT(OTT.OPERATION_BO,2) = ZSD.PREPOSITION_OPERATION AND OTT.LOCALE = 'zh'
WHERE SC.SITE = #{site} AND SC.SFC = #{sfc}
</select>
</mapper>

@ -1,13 +1,12 @@
package com.foreverwin.mesnac.production.controller;
import com.foreverwin.mesnac.meapi.dto.WorkCenterDto;
import com.foreverwin.mesnac.meapi.dto.SfcDto;
import com.foreverwin.mesnac.meapi.dto.WorkCenterDto;
import com.foreverwin.mesnac.production.service.PodTemplateService;
import com.foreverwin.modular.core.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@ -24,7 +23,7 @@ public class PodTemplateController {
*/
@ResponseBody
@GetMapping("/resrceEnter")
public R resrceEnter(@RequestBody WorkCenterDto workCenterDto) {
public R resrceEnter(WorkCenterDto workCenterDto) {
return R.ok(podTemplateService.resrceEnter(workCenterDto));
}
@ -35,7 +34,7 @@ public class PodTemplateController {
*/
@ResponseBody
@GetMapping("/sfcEnter")
public R sfcEnter(@RequestBody SfcDto sfcDto) {
public R sfcEnter(SfcDto sfcDto) {
return R.ok(podTemplateService.sfcEnter(sfcDto));
}
}

@ -0,0 +1,146 @@
package com.foreverwin.mesnac.production.controller;
import com.foreverwin.mesnac.meapi.util.StringUtils;
import com.foreverwin.modular.core.exception.BusinessException;
import com.foreverwin.modular.core.util.R;
import com.foreverwin.modular.core.util.FrontPage;
import com.foreverwin.modular.core.util.CommonMethods;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.foreverwin.mesnac.production.service.SfcDataService;
import com.foreverwin.mesnac.production.model.SfcData;
import java.util.List;
/**
*
* @author Leon.L
* @since 2021-06-29
*/
@RestController
@RequestMapping("/SFC-DATA")
public class SfcDataController {
@Autowired
public SfcDataService sfcDataService;
/**
* id
*
* @param id
* @return
*/
@ResponseBody
@GetMapping("/{id:.+}")
public R getSfcDataById(@PathVariable String id) {
return R.ok( sfcDataService.getById(id));
}
/**
*
*
* @return
*/
@ResponseBody
@GetMapping("")
public R getSfcDataList(SfcData sfcData){
List<SfcData> result;
QueryWrapper<SfcData> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(sfcData);
result = sfcDataService.list(queryWrapper);
return R.ok(result);
}
/**
*
*
* @param frontPage
* @return
*/
@ResponseBody
@GetMapping("/page")
public R page(FrontPage<SfcData> frontPage, SfcData sfcData){
IPage result;
QueryWrapper<SfcData> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(sfcData);
if (frontPage.getGlobalQuery() != null && !"".equals(frontPage.getGlobalQuery().trim())) {
//TODO modify global query
queryWrapper.lambda().and(wrapper -> wrapper
.like(SfcData::getHandle, frontPage.getGlobalQuery())
.or().like(SfcData::getSfcBo, frontPage.getGlobalQuery())
.or().like(SfcData::getDataField, frontPage.getGlobalQuery())
.or().like(SfcData::getDataAttr, frontPage.getGlobalQuery())
.or().like(SfcData::getUserBo, frontPage.getGlobalQuery())
);
}
result = sfcDataService.page(frontPage.getPagePlus(), queryWrapper);
return R.ok(result);
}
/**
*
* @param sfcData
* @return null
*/
@PostMapping
public R save(@RequestBody SfcData sfcData) {
return R.ok(sfcDataService.save(sfcData));
}
/**
*
* @param sfcData
* @return null
*/
@PutMapping
public R updateById(@RequestBody SfcData sfcData) {
return R.ok(sfcDataService.updateById(sfcData));
}
/**
* id
* @param id ID
* @return 0 1
*/
@ResponseBody
@RequestMapping(method = RequestMethod.DELETE, value = "/{id:.+}")
public R removeById(@PathVariable("id") String id){
return R.ok(sfcDataService.removeById(id));
}
/**
*
* @param ids ID
* @return 0 1
*/
@ResponseBody
@RequestMapping(method = RequestMethod.POST, value = "/delete-batch")
public R removeByIds(List<String> ids){
return R.ok(sfcDataService.removeByIds(ids));
}
@ResponseBody
@GetMapping("/saveSfcLocation")
public R saveSfcLocation(String sfc, String location) {
try {
if (StringUtils.isBlank(sfc)) {
throw BusinessException.build("SFC不能为空");
}
if (StringUtils.isBlank(location)) {
throw BusinessException.build("位置不能为空");
}
String site = CommonMethods.getSite();
String user = CommonMethods.getUser();
sfcDataService.saveSfcLocation(site, user, sfc, location);
} catch (Exception e) {
return R.failed(e.getMessage());
}
return R.ok();
}
}

@ -0,0 +1,97 @@
package com.foreverwin.mesnac.production.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.foreverwin.mesnac.meapi.dto.SfcDto;
import com.foreverwin.mesnac.meapi.model.Sfc;
import com.foreverwin.mesnac.meapi.model.ShopOrder;
import com.foreverwin.mesnac.production.model.StepOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
* : sfc
* : philip
* : 2021-6-29 15:56
*/
@Repository
public interface SfcCrossMapper extends BaseMapper {
/**
* SFC
* @param dataField
* @param dataAttr
* @return
*/
List<Sfc> findBindingBarcode(@Param("dataField") String dataField,
@Param("dataAttr") String dataAttr,
@Param("site") String site,
@Param("statusBoList") List<String> statusBoList);
/**
* 线, Sequence
* @param routerBo
* @return
*/
List<StepOperation> findRouterOperationByRouterBo(@Param("site") String site, @Param("routerBo") String routerBo, @Param("locale") String locale);
// String getDoneSfcItemBo(IPage page, @Param("dataAttr") String dataAttr,
// @Param("site") String site, @Param("statusBo") String statusBo);
/**
* SFCSN
* @param site
* @param shopOrderRef
* @return
*/
List<Sfc> findOpenStatusSnByShopOrder(@Param("site") String site, @Param("shopOrderRef") String shopOrderRef);
/**
* 线
* @param plannedWorkCenterBo
* @param customStatus
* @return
*/
List<ShopOrder> findShopOrderListByStatus(@Param("plannedWorkCenterBo") String plannedWorkCenterBo,
@Param("status") String customStatus);
//List<Map<String, Object>> findSfcListBySnList(@Param("site") String site, @Param("snList") List<String> snList);
/**
* 线
* @param page
* @param routerBo
* @return
*/
StepOperation findRouterLastOperationByRouterBo(IPage page, @Param("routerBo") String routerBo);
/**
* SNSFC
* @param page
* @param site
* @param sn
* @return
*/
Sfc findSfcBySn(IPage page, @Param("site") String site, @Param("sn") String sn);
/**
* SNSFC
* @param page
* @param site
* @param sn
* @return
*/
Sfc findSfcBySnContainComplete(IPage page, @Param("site") String site, @Param("sn") String sn);
List<StepOperation> getResourceBySfc(@Param("site") String site, @Param("sfc") String sfc);
Map<String, Object> querySfcData(@Param("site")String site, @Param("locale")String locale, @Param("dto")SfcDto sfcDto);
List<Map<String, Object>> querySfcStep(@Param("site")String site, @Param("sfc")String sfc, @Param("operation")String operation);
}

@ -0,0 +1,18 @@
package com.foreverwin.mesnac.production.mapper;
import com.foreverwin.mesnac.production.model.SfcData;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
/**
* <p>
* Mapper
* </p>
*
* @author Leon.L
* @since 2021-06-29
*/
@Repository
public interface SfcDataMapper extends BaseMapper<SfcData> {
}

@ -0,0 +1,141 @@
package com.foreverwin.mesnac.production.model;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableField;
/**
* <p>
*
* </p>
*
* @author Leon.L
* @since 2021-06-29
*/
@TableName("SFC_DATA")
public class SfcData extends Model<SfcData> {
private static final long serialVersionUID = 1L;
@TableField("HANDLE")
private String handle;
@TableField("SFC_BO")
private String sfcBo;
@TableField("DATE_TIME")
private LocalDateTime dateTime;
@TableField("DATA_FIELD")
private String dataField;
@TableField("DATA_ATTR")
private String dataAttr;
@TableField("USER_BO")
private String userBo;
@TableField("CREATED_DATE_TIME")
private LocalDateTime createdDateTime;
@TableField("MODIFIED_DATE_TIME")
private LocalDateTime modifiedDateTime;
public String getHandle() {
return handle;
}
public void setHandle(String handle) {
this.handle = handle;
}
public String getSfcBo() {
return sfcBo;
}
public void setSfcBo(String sfcBo) {
this.sfcBo = sfcBo;
}
public LocalDateTime getDateTime() {
return dateTime;
}
public void setDateTime(LocalDateTime dateTime) {
this.dateTime = dateTime;
}
public String getDataField() {
return dataField;
}
public void setDataField(String dataField) {
this.dataField = dataField;
}
public String getDataAttr() {
return dataAttr;
}
public void setDataAttr(String dataAttr) {
this.dataAttr = dataAttr;
}
public String getUserBo() {
return userBo;
}
public void setUserBo(String userBo) {
this.userBo = userBo;
}
public LocalDateTime getCreatedDateTime() {
return createdDateTime;
}
public void setCreatedDateTime(LocalDateTime createdDateTime) {
this.createdDateTime = createdDateTime;
}
public LocalDateTime getModifiedDateTime() {
return modifiedDateTime;
}
public void setModifiedDateTime(LocalDateTime modifiedDateTime) {
this.modifiedDateTime = modifiedDateTime;
}
public static final String HANDLE = "HANDLE";
public static final String SFC_BO = "SFC_BO";
public static final String DATE_TIME = "DATE_TIME";
public static final String DATA_FIELD = "DATA_FIELD";
public static final String DATA_ATTR = "DATA_ATTR";
public static final String USER_BO = "USER_BO";
public static final String CREATED_DATE_TIME = "CREATED_DATE_TIME";
public static final String MODIFIED_DATE_TIME = "MODIFIED_DATE_TIME";
@Override
protected Serializable pkVal() {
return this.handle;
}
@Override
public String toString() {
return "SfcData{" +
"handle = " + handle +
", sfcBo = " + sfcBo +
", dateTime = " + dateTime +
", dataField = " + dataField +
", dataAttr = " + dataAttr +
", userBo = " + userBo +
", createdDateTime = " + createdDateTime +
", modifiedDateTime = " + modifiedDateTime +
"}";
}
}

@ -0,0 +1,113 @@
package com.foreverwin.mesnac.production.model;
import java.math.BigDecimal;
/**
* :
* : philip
* : 2021-6-29 08:48
*/
public class StepOperation {
private String operationBo;
private String operation;
private String description;
private String stepId;
private String erpOperation;
private BigDecimal sequence;
/** 步骤排队数量 **/
private BigDecimal qtyInQueue;
/** 步骤在制数量 **/
private BigDecimal qtyInWork;
private String reportingCenterBo;
private String resourceBo;
public String getResourceBo() {
return resourceBo;
}
public void setResourceBo(String resourceBo) {
this.resourceBo = resourceBo;
}
public String getOperationBo() {
return operationBo;
}
public void setOperationBo(String operationBo) {
this.operationBo = operationBo;
}
public String getOperation() {
return operation;
}
public void setOperation(String operation) {
this.operation = operation;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getStepId() {
return stepId;
}
public void setStepId(String stepId) {
this.stepId = stepId;
}
public BigDecimal getSequence() {
return sequence;
}
public void setSequence(BigDecimal sequence) {
this.sequence = sequence;
}
public String getReportingCenterBo() {
return reportingCenterBo;
}
public void setReportingCenterBo(String reportingCenterBo) {
this.reportingCenterBo = reportingCenterBo;
}
public BigDecimal getQtyInQueue() {
return qtyInQueue;
}
public void setQtyInQueue(BigDecimal qtyInQueue) {
this.qtyInQueue = qtyInQueue;
}
public BigDecimal getQtyInWork() {
return qtyInWork;
}
public void setQtyInWork(BigDecimal qtyInWork) {
this.qtyInWork = qtyInWork;
}
public String getErpOperation() {
return erpOperation;
}
public void setErpOperation(String erpOperation) {
this.erpOperation = erpOperation;
}
}

@ -8,5 +8,5 @@ import java.util.Map;
public interface PodTemplateService {
Map<String, Object> resrceEnter(WorkCenterDto workCenterDto);
Object sfcEnter(SfcDto workCenterDto);
Map<String, Object> sfcEnter(SfcDto workCenterDto);
}

@ -0,0 +1,37 @@
package com.foreverwin.mesnac.production.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.foreverwin.mesnac.production.model.SfcData;
import com.baomidou.mybatisplus.extension.service.IService;
import com.foreverwin.modular.core.util.FrontPage;
import java.util.List;
/**
* <p>
*
* </p>
*
* @author Leon.L
* @since 2021-06-29
*/
public interface SfcDataService extends IService<SfcData> {
/**
*
* @param frontPage
* @return
*/
IPage<SfcData> selectPage(FrontPage<SfcData> frontPage, SfcData sfcData);
List<SfcData> selectList(SfcData sfcData);
/**
* SFC
*
* @param site
* @param sfc
* @param location
*/
void saveSfcLocation(String site, String user, String sfc, String location);
}

@ -5,14 +5,17 @@ import com.foreverwin.mesnac.common.service.CommonService;
import com.foreverwin.mesnac.common.util.StringUtil;
import com.foreverwin.mesnac.meapi.dto.SfcDto;
import com.foreverwin.mesnac.meapi.dto.WorkCenterDto;
import com.foreverwin.mesnac.meapi.model.Operation;
import com.foreverwin.mesnac.meapi.model.Resrce;
import com.foreverwin.mesnac.meapi.model.Sfc;
import com.foreverwin.mesnac.meapi.service.ResrceService;
import com.foreverwin.mesnac.meapi.service.SfcService;
import com.foreverwin.mesnac.production.mapper.SfcCrossMapper;
import com.foreverwin.mesnac.production.service.PodTemplateService;
import com.foreverwin.modular.core.exception.BaseException;
import com.foreverwin.modular.core.util.CommonMethods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -30,6 +33,8 @@ public class PodTemplateServiceImpl implements PodTemplateService {
private SfcService sfcService;
@Autowired
private CommonService commonService;
@Autowired
private SfcCrossMapper sfcCrossMapper;
@Override
public Map<String, Object> resrceEnter(WorkCenterDto workCenterDto) {
@ -60,135 +65,135 @@ public class PodTemplateServiceImpl implements PodTemplateService {
}
@Override
public Object sfcEnter(SfcDto sfcDto) {
// String site = CommonMethods.getSite();
// String sfc = sfcDto.getSfc();
// String operation = sfcDto.getOperation();
// //校验产品条码是否存在
// Sfc sfcById = sfcService.getById(HandleEnum.SFC.getHandle(site, sfc));
// if (sfcById==null){
// throw new BaseException("产品条码"+sfc+"不存在");
// }
// //校验产品条码是否在当前工序排队
// Operation operationBySfcBo = commonService.getOperationBySfcBo(sfcById.getHandle());
// if (!operationBySfcBo.getOperation().equals(operation)){
// throw new BaseException("产品条码"+sfc+"在"+operationBySfcBo.getDescription()+"工序");
// }
// //校验SFC+工序+设备+STEP_ID是否与当前设备确认的派工单匹配
//
// String substep = "";
// String substepHandle = "";
// //构造前台所需要的数据
// Map<String, Object> resultMap = sfcDataMainMapper.querySfcData(paramMap);
// if(resultMap == null){
// throw new BaseException("根据当前资源未找到条码[" + sfc + "]的基本信息!");
// }
// List<Map<String, Object>> substepList = sfcDataMainMapper.querySfcStep(site, sfc, operation);
// resultMap.put("SFC_STEP_LIST", substepList);
//
// String stepId = (String) resultMap.get("STEP_ID");
// //2021/1/20 roc 根据SFC和步骤标识查找是否维护了尾检项
// List<Map<String, Object>> checkOperationCheckW = sfcDataMainMapper.checkOperationCheckW(site, sfc, stepId);
// if(null != checkOperationCheckW && checkOperationCheckW.size() >0){
// resultMap.put("IS_CREATE_W", "Y");
// }else{
// resultMap.put("IS_CREATE_W", "N");
// }
//
// String isCreateH = "Y";
// String isCreateZ = "Y";
// if(!"403".equals(resultMap.get("STATUS"))) {
// //SFC未开始
// //判断对否需要进行互检
// List<Map<String, Object>> checkOperationCheckH = sfcDataMainMapper.checkOperationCheckH(site, sfc, stepId);
// if(checkOperationCheckH.size() > 0 ){
// resultMap.put("IS_CHECK_H", "Y");
// //自检/互检 校验是否在当前工序+工序标识 做过检验任务
// List<Map<String, Object>> checkList = taskMapper.checkCreateTaskSfc(sfc, site, "H", (String) resultMap.get("OPERATION"), stepId);
// if (checkList.size() > 0) {
// for (int i = 0; i < checkList.size(); i++) {
// if (checkList.get(i).get("STATUS").equals("COMPLETE") && checkList.get(i).get("RESULT").equals("OK")) {
// isCreateH = "N";
// }
// }
// }
//
// }
// }else{
// //sfc已开始
// for (int i = 0; i < substepList.size(); i++) {
// if ("READY".equals(substepList.get(i).get("STATE")) && "true".equals(substepList.get(i).get("IS_SEQTRUE"))) {
// substep = (String) substepList.get(i).get("STEP_ID");
// substepHandle = (String) substepList.get(i).get("HANDLE");
// }
// }
// //判断是否存在工步
// if(StringUtils.isEmpty(substep)){
// //判断对否需要进行自检(无工步)
// List<Map<String, Object>> checkOperationCheckZ = sfcDataMainMapper.checkOperationCheckZ(site, sfc, stepId);
// if(checkOperationCheckZ.size() > 0 ){
// resultMap.put("IS_CHECK_Z", "Y");
// //自检/互检 校验是否在当前工序+工序标识 做过检验任务
// List<Map<String, Object>> checkList = taskMapper.checkCreateTaskSfc(sfc, site, "Z", (String) resultMap.get("OPERATION"), stepId);
// if (checkList.size() > 0) {
// for (int i = 0; i < checkList.size(); i++) {
// if (checkList.get(i).get("STATUS").equals("COMPLETE") && "OK".equals(checkList.get(i).get("RESULT"))) {
// isCreateZ = "N";
// }
// }
// }
//
// }
//
// //判断对否需要进行互检(无工步)
// List<Map<String, Object>> checkOperationCheckH = sfcDataMainMapper.checkOperationCheckH(site, sfc, stepId);
// if(checkOperationCheckH.size() > 0 ){
// resultMap.put("IS_CHECK_H", "Y");
// //自检/互检 校验是否在当前工序+工序标识 做过检验任务
// List<Map<String, Object>> checkList = taskMapper.checkCreateTaskSfc(sfc, site, "H", (String) resultMap.get("OPERATION"), stepId);
// if (checkList.size() > 0) {
// for (int i = 0; i < checkList.size(); i++) {
// if (checkList.get(i).get("STATUS").equals("COMPLETE") && "OK".equals(checkList.get(i).get("RESULT"))) {
// isCreateH = "N";
// }
// }
// }
// }
// }else{
// //判断对否需要进行自检(有工步)
// List<Map<String, Object>> checkSubstepCheckZ = sfcDataMainMapper.checkSubstepCheckZ(substepHandle);
// if(checkSubstepCheckZ.size() > 0 ){
// resultMap.put("IS_CHECK_Z", "Y");
// //自检/互检 校验是否在当前工序+工序+工步标识 做过检验任务
// List<Map<String, Object>> checkList = taskMapper.checkCreateTaskSfcDetail(sfc, site, "Z", (String) resultMap.get("OPERATION"), stepId, substep);
// if (checkList.size() > 0) {
// for (int i = 0; i < checkList.size(); i++) {
// if (checkList.get(i).get("STATUS").equals("COMPLETE") && "OK".equals(checkList.get(i).get("RESULT"))) {
// isCreateZ = "N";
// }
// }
// }
//
// }
//
// //判断对否需要进行互检(有工步)
// List<Map<String, Object>> checkSubstepCheckH = sfcDataMainMapper.checkSubstepCheckH(substepHandle);
// if(checkSubstepCheckH.size() > 0 ){
// resultMap.put("IS_CHECK_H", "Y");
// //自检/互检 校验是否在当前工序+工序标识 做过检验任务
// List<Map<String, Object>> checkList = taskMapper.checkCreateTaskSfcDetail(sfc, site, "H", (String) resultMap.get("OPERATION"), stepId, substep);
// if (checkList.size() > 0) {
// for (int i = 0; i < checkList.size(); i++) {
// if (checkList.get(i).get("STATUS").equals("COMPLETE") && "OK".equals(checkList.get(i).get("RESULT"))) {
// isCreateH = "N";
// }
// }
// }
// }
// }
// }
// resultMap.put("IS_CREATE_H", isCreateH);
// resultMap.put("IS_CREATE_Z", isCreateZ);
public Map<String, Object> sfcEnter(SfcDto sfcDto) {
String site = CommonMethods.getSite();
String sfc = sfcDto.getSfc();
String operation = sfcDto.getOperation();
String locale = LocaleContextHolder.getLocale().getLanguage();
//校验产品条码是否存在
Sfc sfcById = sfcService.getById(HandleEnum.SFC.getHandle(site, sfc));
if (sfcById==null){
throw new BaseException("产品条码"+sfc+"不存在");
}
//校验产品条码是否在当前工序排队
Operation operationBySfcBo = commonService.getOperationBySfcBo(sfcById.getHandle());
if (StringUtil.notBlank(operation)&&!operationBySfcBo.getOperation().equals(operation)){
throw new BaseException("产品条码"+sfc+"在"+operationBySfcBo.getOperation()+"/"+operationBySfcBo.getDescription()+"工序");
}
//校验SFC+工序+设备+STEP_ID是否与当前设备确认的派工单匹配
String substep = "";
String substepHandle = "";
//构造前台所需要的数据
Map<String, Object> resultMap = sfcCrossMapper.querySfcData(site,locale,sfcDto);
if(resultMap == null){
throw new BaseException("根据当前资源未找到条码[" + sfc + "]的基本信息!");
}
List<Map<String, Object>> substepList = sfcCrossMapper.querySfcStep(site, sfc, operation);
resultMap.put("SFC_STEP_LIST", substepList);
String stepId = (String) resultMap.get("STEP_ID");
//2021/1/20 roc 根据SFC和步骤标识查找是否维护了尾检项
/*List<Map<String, Object>> checkOperationCheckW = sfcDataMainMapper.checkOperationCheckW(site, sfc, stepId);
if(null != checkOperationCheckW && checkOperationCheckW.size() >0){
resultMap.put("IS_CREATE_W", "Y");
}else{
resultMap.put("IS_CREATE_W", "N");
}*/
resultMap.put("IS_CREATE_W", "N");
String isCreateH = "N";
String isCreateZ = "N";
/*if(!"403".equals(resultMap.get("STATUS"))) {
//SFC未开始
//判断对否需要进行互检
*//* List<Map<String, Object>> checkOperationCheckH = sfcDataMainMapper.checkOperationCheckH(site, sfc, stepId);
if(checkOperationCheckH.size() > 0 ){
resultMap.put("IS_CHECK_H", "Y");
//自检/互检 校验是否在当前工序+工序标识 做过检验任务
List<Map<String, Object>> checkList = taskMapper.checkCreateTaskSfc(sfc, site, "H", (String) resultMap.get("OPERATION"), stepId);
if (checkList.size() > 0) {
for (int i = 0; i < checkList.size(); i++) {
if (checkList.get(i).get("STATUS").equals("COMPLETE") && checkList.get(i).get("RESULT").equals("OK")) {
isCreateH = "N";
}
}
}
}*//*
}else{
//sfc已开始
for (int i = 0; i < substepList.size(); i++) {
if ("READY".equals(substepList.get(i).get("STATE")) && "true".equals(substepList.get(i).get("IS_SEQTRUE"))) {
substep = (String) substepList.get(i).get("STEP_ID");
substepHandle = (String) substepList.get(i).get("HANDLE");
}
}
//判断是否存在工步
if(StringUtil.isEmpty(substep)){
//判断对否需要进行自检(无工步)
List<Map<String, Object>> checkOperationCheckZ = sfcDataMainMapper.checkOperationCheckZ(site, sfc, stepId);
if(checkOperationCheckZ.size() > 0 ){
resultMap.put("IS_CHECK_Z", "Y");
//自检/互检 校验是否在当前工序+工序标识 做过检验任务
List<Map<String, Object>> checkList = taskMapper.checkCreateTaskSfc(sfc, site, "Z", (String) resultMap.get("OPERATION"), stepId);
if (checkList.size() > 0) {
for (int i = 0; i < checkList.size(); i++) {
if (checkList.get(i).get("STATUS").equals("COMPLETE") && "OK".equals(checkList.get(i).get("RESULT"))) {
isCreateZ = "N";
}
}
}
}
//判断对否需要进行互检(无工步)
List<Map<String, Object>> checkOperationCheckH = sfcDataMainMapper.checkOperationCheckH(site, sfc, stepId);
if(checkOperationCheckH.size() > 0 ){
resultMap.put("IS_CHECK_H", "Y");
//自检/互检 校验是否在当前工序+工序标识 做过检验任务
List<Map<String, Object>> checkList = taskMapper.checkCreateTaskSfc(sfc, site, "H", (String) resultMap.get("OPERATION"), stepId);
if (checkList.size() > 0) {
for (int i = 0; i < checkList.size(); i++) {
if (checkList.get(i).get("STATUS").equals("COMPLETE") && "OK".equals(checkList.get(i).get("RESULT"))) {
isCreateH = "N";
}
}
}
}
}else{
//判断对否需要进行自检(有工步)
List<Map<String, Object>> checkSubstepCheckZ = sfcDataMainMapper.checkSubstepCheckZ(substepHandle);
if(checkSubstepCheckZ.size() > 0 ){
resultMap.put("IS_CHECK_Z", "Y");
//自检/互检 校验是否在当前工序+工序+工步标识 做过检验任务
List<Map<String, Object>> checkList = taskMapper.checkCreateTaskSfcDetail(sfc, site, "Z", (String) resultMap.get("OPERATION"), stepId, substep);
if (checkList.size() > 0) {
for (int i = 0; i < checkList.size(); i++) {
if (checkList.get(i).get("STATUS").equals("COMPLETE") && "OK".equals(checkList.get(i).get("RESULT"))) {
isCreateZ = "N";
}
}
}
}
//判断对否需要进行互检(有工步)
List<Map<String, Object>> checkSubstepCheckH = sfcDataMainMapper.checkSubstepCheckH(substepHandle);
if(checkSubstepCheckH.size() > 0 ){
resultMap.put("IS_CHECK_H", "Y");
//自检/互检 校验是否在当前工序+工序标识 做过检验任务
List<Map<String, Object>> checkList = taskMapper.checkCreateTaskSfcDetail(sfc, site, "H", (String) resultMap.get("OPERATION"), stepId, substep);
if (checkList.size() > 0) {
for (int i = 0; i < checkList.size(); i++) {
if (checkList.get(i).get("STATUS").equals("COMPLETE") && "OK".equals(checkList.get(i).get("RESULT"))) {
isCreateH = "N";
}
}
}
}
}
}*/
resultMap.put("IS_CREATE_H", isCreateH);
resultMap.put("IS_CREATE_Z", isCreateZ);
return null;
}
}

@ -0,0 +1,114 @@
package com.foreverwin.mesnac.production.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.foreverwin.mesnac.common.constant.CustomFieldConstant;
import com.foreverwin.mesnac.common.enums.HandleEnum;
import com.foreverwin.mesnac.meapi.model.Sfc;
import com.foreverwin.mesnac.meapi.model.WorkCenter;
import com.foreverwin.mesnac.meapi.service.SfcService;
import com.foreverwin.mesnac.meapi.service.WorkCenterService;
import com.foreverwin.modular.core.exception.BusinessException;
import com.foreverwin.modular.core.util.FrontPage;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.foreverwin.mesnac.production.model.SfcData;
import com.foreverwin.mesnac.production.mapper.SfcDataMapper;
import com.foreverwin.mesnac.production.service.SfcDataService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <p>
*
* </p>
*
* @author Leon.L
* @since 2021-06-29
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class SfcDataServiceImpl extends ServiceImpl<SfcDataMapper, SfcData> implements SfcDataService {
@Autowired
private SfcService sfcService;
@Autowired
private SfcDataMapper sfcDataMapper;
@Autowired
private WorkCenterService workCenterService;
@Override
public IPage<SfcData> selectPage(FrontPage<SfcData> frontPage, SfcData sfcData) {
QueryWrapper<SfcData> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(sfcData);
return super.page(frontPage.getPagePlus(), queryWrapper);
}
@Override
public List<SfcData> selectList(SfcData sfcData) {
QueryWrapper<SfcData> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(sfcData);
return super.list(queryWrapper);
}
@Override
public void saveSfcLocation(String site, String user, String sfc, String location) {
String sfcBo = HandleEnum.SFC.getHandle(site, sfc);
Sfc sfcModel = sfcService.getById(sfcBo);
if (sfcModel == null) {
throw BusinessException.build("SFC【" +sfc+"】不存在");
}
//位置所录入的字符串“_”前的字符为车间代码
if (!location.contains("_")) {
throw BusinessException.build("输入的位置【" +location+ "】格式不正确必须包含符号【_】,并且符号之前必须是车间代码");
}
String workCenterBo = HandleEnum.WORK_CENTER.getHandle(site, location.split("_")[0]);
WorkCenter workCenterModel = workCenterService.getById(workCenterBo);
if (workCenterModel == null || !"LEVEL4".equals(workCenterModel.getWcCategory())) {
throw BusinessException.build("位置【" +location+"】中符号【_】之前的不是车间代码");
}
LocalDateTime nowDate = LocalDateTime.now();
//查询是否存在
Map<String, Object> map = new HashMap<>();
map.put(SfcData.SFC_BO, sfcBo);
map.put(SfcData.DATA_FIELD, CustomFieldConstant.SFC_DATA_LOCATION);
List<SfcData> sfcDataList = sfcDataMapper.selectByMap(map);
if (sfcDataList == null || sfcDataList.size() <= 0) {
//记录位置到SFC
SfcData sfcData = new SfcData();
sfcData.setHandle(HandleEnum.SFC_DATA.getHandle(site, sfcBo, CustomFieldConstant.SFC_DATA_LOCATION));
sfcData.setSfcBo(sfcBo);
sfcData.setDataField(CustomFieldConstant.SFC_DATA_LOCATION);
sfcData.setDataAttr(location);
sfcData.setDateTime(nowDate);
sfcData.setUserBo(HandleEnum.USER.getHandle(site, user));
sfcData.setCreatedDateTime(nowDate);
sfcDataMapper.insert(sfcData);
} else {
//更新位置到SFC
SfcData sfcData = sfcDataList.get(0);
sfcData.setDataAttr(location);
sfcData.setDateTime(nowDate);
sfcData.setModifiedDateTime(nowDate);
Wrapper<SfcData> updateWrapper = new UpdateWrapper<>();
SfcData tjSfcData = new SfcData();
tjSfcData.setSfcBo(sfcBo);
tjSfcData.setDataField(CustomFieldConstant.SFC_DATA_LOCATION);
((UpdateWrapper<SfcData>) updateWrapper).setEntity(tjSfcData);
sfcDataMapper.update(sfcData, updateWrapper);
}
}
}

@ -0,0 +1,211 @@
<?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.foreverwin.mesnac.production.mapper.SfcCrossMapper">
<resultMap id="StepOperationMap" type="com.foreverwin.mesnac.production.model.StepOperation">
<result property="operationBo" column="OPERATION_BO" />
<result property="stepId" column="STEP_ID" />
<result property="sequence" column="SEQUENCE" javaType="java.math.BigDecimal" />
<result property="reportingCenterBo" column="REPORTING_CENTER_BO" />
<result property="operation" column="OPERATION" />
<result property="description" column="DESCRIPTION" />
<result property="resourceBo" column="RESOURCE_BO" />
</resultMap>
<select id="findBindingBarcode" resultMap="com.foreverwin.mesnac.meapi.mapper.SfcMapper.BaseResultMap">
SELECT
SFC.HANDLE,
SFC.SFC,
SFC.SHOP_ORDER_BO,
SFC.STATUS_BO
FROM SFC SFC
JOIN SFC_DATA DT ON DT.SFC_BO = SFC.HANDLE AND DT.DATA_FIELD = #{dataField}
WHERE DT.DATA_ATTR = #{dataAttr}
AND SFC.SITE = #{site}
<if test="statusBoList != null and statusBoList.size() > 0">
AND SFC.STATUS_BO IN
<foreach collection="statusBoList" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
ORDER BY DT.DATE_TIME DESC
</select>
<select id="findRouterOperationByRouterBo" resultMap="StepOperationMap">
SELECT
STEP.STEP_ID ,
STEP."SEQUENCE",
STEP.REPORTING_CENTER_BO,
STEP.ERP_OPERATION ,
OP.HANDLE AS OPERATION_BO,
OP.OPERATION ,
OPT.DESCRIPTION
FROM ROUTER R
JOIN ROUTER_STEP STEP ON R.HANDLE = STEP.ROUTER_BO
JOIN ROUTER_OPERATION RO ON STEP.HANDLE = RO.ROUTER_STEP_BO
JOIN OPERATION OP ON 'OperationBO:' || #{site} || ',' || OP.OPERATION || ',#' = RO.OPERATION_BO AND OP.CURRENT_REVISION = 'true'
JOIN OPERATION_T OPT ON OP.HANDLE = OPT.OPERATION_BO AND OPT.LOCALE='zh'
WHERE R.HANDLE = #{routerBo}
AND OP.SITE = #{site}
AND OPT.LOCALE = #{locale}
ORDER BY STEP."SEQUENCE"
</select>
<select id="findRouterLastOperationByRouterBo" resultMap="StepOperationMap">
SELECT
STEP.STEP_ID ,
STEP."SEQUENCE",
RO.OPERATION_BO
FROM ROUTER R
JOIN ROUTER_STEP STEP ON R.HANDLE = STEP.ROUTER_BO
JOIN ROUTER_OPERATION RO ON STEP.HANDLE = RO.ROUTER_STEP_BO
WHERE R.HANDLE = #{routerBo}
ORDER BY STEP."SEQUENCE" DESC
</select>
<select id="findShopOrderListByStatus" resultMap="com.foreverwin.mesnac.meapi.mapper.ShopOrderMapper.BaseResultMap">
SELECT
ORD.HANDLE,
ORD.SHOP_ORDER,
ORD.PLANNED_ITEM_BO,
ORD.ITEM_BO
FROM SHOP_ORDER ORD
JOIN CUSTOM_FIELDS CF ON ORD.HANDLE = CF.HANDLE AND CF.ATTRIBUTE = 'WORK_ORDER_STATUS'
WHERE ORD.PLANNED_WORK_CENTER_BO = #{plannedWorkCenterBo}
AND CF.VALUE = #{status}
</select>
<select id="findOpenStatusSnByShopOrder" resultMap="com.foreverwin.mesnac.meapi.mapper.SfcMapper.BaseResultMap">
SELECT
SFC.SFC,
SFC.QTY ,
SFC.CREATED_DATE_TIME
FROM SFC SFC
WHERE SFC.SHOP_ORDER_BO = #{shopOrderRef}
AND SFC.SITE = #{site}
AND SFC.STATUS_BO IN ('StatusBO:' || #{site} || ',403', 'StatusBO:' || #{site} || ',402')
ORDER BY SFC.CREATED_DATE_TIME DESC
</select>
<select id="findSfcBySn" resultMap="com.foreverwin.mesnac.meapi.mapper.SfcMapper.BaseResultMap">
SELECT
SFC.HANDLE,
SFC.SFC,
SFC.STATUS_BO,
SFC.SHOP_ORDER_BO,
SFC.QTY,
SFC.ITEM_BO
FROM SFC SFC
JOIN SFC_DATA SD ON SFC.HANDLE = SD.SFC_BO AND SD.DATA_FIELD = 'SN'
WHERE SFC.SITE = #{site}
AND SD.DATA_ATTR = #{sn}
AND SFC.STATUS_BO IN ('StatusBO:' || #{site} || ',403', 'StatusBO:' || #{site} || ',402' , 'StatusBO:'|| #{site} || ',401')
ORDER BY SFC.CREATED_DATE_TIME DESC
</select>
<select id="findSfcBySnContainComplete" resultMap="com.foreverwin.mesnac.meapi.mapper.SfcMapper.BaseResultMap">
SELECT
SFC.HANDLE,
SFC.SFC,
SFC.STATUS_BO,
SFC.SHOP_ORDER_BO,
SFC.QTY,
SFC.ITEM_BO
FROM SFC SFC
JOIN SFC_DATA SD ON SFC.HANDLE = SD.SFC_BO AND SD.DATA_FIELD = 'SN'
WHERE SFC.SITE = #{site}
AND SD.DATA_ATTR = #{sn}
AND SFC.STATUS_BO IN ('StatusBO:' || #{site} || ',403', 'StatusBO:' || #{site} || ',402','StatusBO:' || #{site} || ',405')
ORDER BY SFC.CREATED_DATE_TIME DESC
</select>
<select id="getResourceBySfc" resultMap="StepOperationMap">
select siw.RESOURCE_BO
from sfc as sfc
inner join sfc_routing as sri on sfc.handle = sri.sfc_bo
inner join sfc_router as srt on sri.handle = srt.sfc_routing_bo
inner join sfc_step as sep on srt.handle = sep.sfc_router_bo
INNER JOIN SFC_IN_WORK siw ON sep.HANDLE = siw.SFC_STEP_BO
WHERE sfc.site = #{site} and
sfc.SFC = #{sfc}
</select>
<select id="querySfcData" resultType="map">
SELECT SO.SHOP_ORDER, SO_CF.VALUE ITEM_NUMBER, I.ITEM, IT.DESCRIPTION ITEM_DESC,
CASE WHEN ST.STATUS='403' AND SS.QTY_IN_QUEUE > 0 THEN N'402' ELSE ST.STATUS END STATUS,
OP.OPERATION, OT.DESCRIPTION OPERATION_DESC,OP.OPERATION||'/'||RS.STEP_ID OPERATION_STEP,
RO_CF2.VALUE TOOL ,SOD.HANDLE SFC_DISPATCH_DETAIL_BO,
S.SFC,S.QTY SFC_QTY,RS.STEP_ID, SOD.DISPATCH_NO ,
TO_CHAR( SOD.PLANNED_START_DATE + INTERVAL '8' HOUR,'yyyy-mm-dd hh24:mi:ss')START_DATE,
TO_CHAR(SOD.PLANNED_COMPLETE_DATE + INTERVAL '8' HOUR ,'yyyy-mm-dd hh24:mi:ss')COMP_DATE,
TO_CHAR((SOD.PLANNED_COMPLETE_DATE - SOD.PLANNED_START_DATE )*24,'fm9999999990.00')||'H' ADD_DATE,
CASE WHEN OT.DESCRIPTION LIKE 'CH%' THEN SUBSTR(OT.DESCRIPTION, 0, 3) ELSE N'' END SLOT
FROM SFC S
INNER JOIN STATUS ST ON ST.HANDLE = S.STATUS_BO
INNER JOIN SFC_ROUTING SR ON SR.SFC_BO = S.HANDLE
INNER JOIN SFC_ROUTER SRO ON SRO.SFC_ROUTING_BO = SR.HANDLE AND SRO.IN_USE = 'true'
INNER JOIN SFC_STEP SS ON SS.SFC_ROUTER_BO = SRO.HANDLE AND (SS.QTY_IN_QUEUE > 0 OR SS.QTY_IN_WORK > 0)
INNER JOIN ROUTER RO ON SRO.ROUTER_BO = RO.HANDLE
INNER JOIN ROUTER_STEP RS ON RS.ROUTER_BO = RO.HANDLE AND RS.STEP_ID = SS.STEP_ID
INNER JOIN ROUTER_OPERATION ROP ON ROP.HANDLE = RS.ROUTER_COMP_GBO AND SS.OPERATION_BO = ROP.OPERATION_BO
LEFT JOIN CUSTOM_FIELDS RO_CF2 ON RO_CF2.HANDLE = ROP.HANDLE AND RO_CF2."ATTRIBUTE" = 'TOOL_NUMBER'
INNER JOIN OPERATION OP ON 'OperationBO:'||OP.SITE||','||OP.OPERATION||',#' = SS.OPERATION_BO AND OP.CURRENT_REVISION='true'
AND (#{dto.operation} IS NULL OR OP.OPERATION = #{dto.operation})
LEFT JOIN OPERATION_T OT ON OT.OPERATION_BO = OP.HANDLE AND OT.LOCALE =#{locale}
INNER JOIN SHOP_ORDER SO ON SO.HANDLE = S.SHOP_ORDER_BO
LEFT JOIN CUSTOM_FIELDS SO_CF ON SO_CF.HANDLE = SO.HANDLE AND SO_CF."ATTRIBUTE" = 'ITEM_NUMBER'
INNER JOIN ITEM I ON I.HANDLE = S.ITEM_BO
LEFT JOIN ITEM_T IT ON IT.ITEM_BO = I.HANDLE AND IT.LOCALE =#{locale}
INNER JOIN (
SELECT SD.HANDLE, SD.SFC,SD.RESRCE,SD.OPERATION,SD.STEP_ID,SD.PLANNED_COMPLETE_DATE, SD.PLANNED_START_DATE,SD.DISPATCH_NO
FROM Z_PROD_READY_TASK RB
INNER JOIN Z_SFC_DISPATCH SD ON SD.HANDLE = RB.SFC_DISPATCH_BO
WHERE RB.SITE =#{site} AND RB.STATUS = 'F'
) SOD ON SOD.RESRCE =#{dto.resrce} AND SOD.SFC= S.SFC AND SOD.OPERATION = OP.OPERATION
WHERE S.SITE = #{site} AND S.SFC = #{dto.sfc} AND ROWNUM=1
GROUP BY SO.SHOP_ORDER, SO_CF.VALUE , I.ITEM, IT.DESCRIPTION ,
CASE WHEN ST.STATUS='403' AND SS.QTY_IN_QUEUE > 0 THEN N'402' ELSE ST.STATUS END,
OP.OPERATION, OT.DESCRIPTION ,OP.OPERATION||'/'||RS.STEP_ID ,RO_CF2.VALUE,
S.SFC,S.QTY ,RS.STEP_ID,SOD.DISPATCH_NO , SOD.HANDLE ,
TO_CHAR( SOD.PLANNED_START_DATE + INTERVAL '8' HOUR,'yyyy-mm-dd hh24:mi:ss'),
TO_CHAR(SOD.PLANNED_COMPLETE_DATE + INTERVAL '8' HOUR,'yyyy-mm-dd hh24:mi:ss'),
TO_CHAR((SOD.PLANNED_COMPLETE_DATE - SOD.PLANNED_START_DATE )*24,'fm9999999990.00')||'H',
CASE WHEN OT.DESCRIPTION LIKE 'CH%' THEN SUBSTR(OT.DESCRIPTION, 0, 3) ELSE N'' END
</select>
<select id="querySfcStep" resultType="map">
SELECT B1.OPERATION,B1.STEP_ID,B1.DESCRIPTION STEP_DESC,B1.STATE,
B1.HANDLE,B1."SEQUENCE",
CASE WHEN B1."SEQUENCE"=B1.MAXSEQ THEN 'true'
ELSE 'false' END IS_SEQTRUE,B1.LONG_DESCRIPTION,
CASE WHEN B1.STATE ='FINISHED' THEN N'已完工'
WHEN B1."SEQUENCE"=B1.MAXSEQ AND B1.STATE ='READY' AND B1.STATUS ='403' THEN N'加工中'
ELSE N'未加工'
END STEP_STATUS
FROM (
SELECT A1.*,MAX(A1.SELECTSEQ) OVER(PARTITION BY OPERATION) MAXSEQ
FROM (
SELECT O.OPERATION,SST.SUBSTEP STEP_ID,SS.STATE,
NVL(SST.DESCRIPTION,SU.DESCRIPTION) DESCRIPTION,
CASE WHEN SS.STATE ='FINISHED' THEN N'已完工' ELSE N'加工中' END STEP_STATUS,
SS.HANDLE,SS."SEQUENCE",
CASE WHEN SS.STATE='FINISHED' THEN SST."SEQUENCE"+1 ELSE 0 END SELECTSEQ,ST.STATUS,
NVL(SST.LONG_DESCRIPTION,SU.LONG_DESCRIPTION) LONG_DESCRIPTION
FROM SFC_SUBSTEP SS
INNER JOIN SFC_STEP SSTEP ON SS.SFC_STEP_BO=SSTEP.HANDLE AND SSTEP.DONE='false'
AND (SSTEP.QTY_IN_QUEUE > 0 OR SSTEP.QTY_IN_WORK > 0)
INNER JOIN SFC_ROUTER SR ON SR.HANDLE=SSTEP.SFC_ROUTER_BO
INNER JOIN SFC_ROUTING SRI ON SRI.HANDLE=SR.SFC_ROUTING_BO
INNER JOIN ROUTER_SUBSTEP SST ON SS.ROUTER_SUBSTEP_BO = SST.HANDLE
LEFT JOIN SUBSTEP SU ON SU.SUBSTEP = SST.SUBSTEP AND SU.CURRENT_REVISION = 'true' AND SU.SITE = #{site}
INNER JOIN SFC S ON S.HANDLE=SRI.SFC_BO
INNER JOIN STATUS ST ON ST.HANDLE = S.STATUS_BO
INNER JOIN OPERATION O ON O.OPERATION=SPLIT(SSTEP.OPERATION_BO,2) AND O.SITE=S.SITE AND O.CURRENT_REVISION = 'true'
AND #{operation} IS NULL OR #{operation} = O.OPERATION)
WHERE S.SFC=#{sfc} AND S.SITE= #{site} ORDER BY SST."SEQUENCE"
) A1
) B1 ORDER BY B1."SEQUENCE" ASC
</select>
</mapper>

@ -0,0 +1,332 @@
<?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.foreverwin.mesnac.production.mapper.SfcDataMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.foreverwin.mesnac.production.model.SfcData">
<result column="HANDLE" property="handle" />
<result column="SFC_BO" property="sfcBo" />
<result column="DATE_TIME" property="dateTime" />
<result column="DATA_FIELD" property="dataField" />
<result column="DATA_ATTR" property="dataAttr" />
<result column="USER_BO" property="userBo" />
<result column="CREATED_DATE_TIME" property="createdDateTime" />
<result column="MODIFIED_DATE_TIME" property="modifiedDateTime" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
HANDLE, SFC_BO, DATE_TIME, DATA_FIELD, DATA_ATTR, USER_BO, CREATED_DATE_TIME, MODIFIED_DATE_TIME
</sql>
<!-- BaseMapper标准查询/修改/删除 -->
<select id="selectByMap" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"></include>
FROM SFC_DATA
<if test="cm!=null and !cm.isEmpty">
<where>
<foreach collection="cm.keys" item="k" separator="AND">
<if test="cm[k] != null">
${k} = #{cm[${k}]}
</if>
</foreach>
</where>
</if>
</select>
<select id="selectOne" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"></include> FROM SFC_DATA
<where>
<if test="ew.entity.handle!=null">
HANDLE=#{ew.handle}
</if>
<if test="ew.entity.sfcBo!=null"> AND SFC_BO=#{ew.entity.sfcBo}</if>
<if test="ew.entity.dateTime!=null"> AND DATE_TIME=#{ew.entity.dateTime}</if>
<if test="ew.entity.dataField!=null"> AND DATA_FIELD=#{ew.entity.dataField}</if>
<if test="ew.entity.dataAttr!=null"> AND DATA_ATTR=#{ew.entity.dataAttr}</if>
<if test="ew.entity.userBo!=null"> AND USER_BO=#{ew.entity.userBo}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
</where>
</select>
<select id="selectCount" resultType="Integer">
SELECT COUNT(1) FROM SFC_DATA
<where>
<if test="ew!=null">
<if test="ew.entity!=null">
<if test="ew.entity.handle!=null">
HANDLE=#{ew.entity.handle}
</if>
<if test="ew.entity.sfcBo!=null"> AND SFC_BO=#{ew.entity.sfcBo}</if>
<if test="ew.entity.dateTime!=null"> AND DATE_TIME=#{ew.entity.dateTime}</if>
<if test="ew.entity.dataField!=null"> AND DATA_FIELD=#{ew.entity.dataField}</if>
<if test="ew.entity.dataAttr!=null"> AND DATA_ATTR=#{ew.entity.dataAttr}</if>
<if test="ew.entity.userBo!=null"> AND USER_BO=#{ew.entity.userBo}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
</if>
</if>
</where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
${ew.sqlSegment}
</if>
</select>
<select id="selectList" resultMap="BaseResultMap">
SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM SFC_DATA
<where>
<if test="ew!=null">
<if test="ew.entity!=null">
<if test="ew.entity.handle!=null">
HANDLE=#{ew.entity.handle}
</if>
<if test="ew.entity.sfcBo!=null"> AND SFC_BO=#{ew.entity.sfcBo}</if>
<if test="ew.entity.dateTime!=null"> AND DATE_TIME=#{ew.entity.dateTime}</if>
<if test="ew.entity.dataField!=null"> AND DATA_FIELD=#{ew.entity.dataField}</if>
<if test="ew.entity.dataAttr!=null"> AND DATA_ATTR=#{ew.entity.dataAttr}</if>
<if test="ew.entity.userBo!=null"> AND USER_BO=#{ew.entity.userBo}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
</if>
</if>
</where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
${ew.sqlSegment}
</if>
</select>
<select id="selectMaps" resultType="HashMap">
SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM SFC_DATA
<where>
<if test="ew!=null">
<if test="ew.entity!=null">
<if test="ew.entity.handle!=null">
HANDLE=#{ew.entity.handle}
</if>
<if test="ew.entity.sfcBo!=null"> AND SFC_BO=#{ew.entity.sfcBo}</if>
<if test="ew.entity.dateTime!=null"> AND DATE_TIME=#{ew.entity.dateTime}</if>
<if test="ew.entity.dataField!=null"> AND DATA_FIELD=#{ew.entity.dataField}</if>
<if test="ew.entity.dataAttr!=null"> AND DATA_ATTR=#{ew.entity.dataAttr}</if>
<if test="ew.entity.userBo!=null"> AND USER_BO=#{ew.entity.userBo}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
</if>
</if>
</where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
${ew.sqlSegment}
</if>
</select>
<select id="selectObjs" resultType="Object">
SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM SFC_DATA
<where>
<if test="ew!=null">
<if test="ew.entity!=null">
<if test="ew.entity.handle!=null">
HANDLE=#{ew.entity.handle}
</if>
<if test="ew.entity.sfcBo!=null"> AND SFC_BO=#{ew.entity.sfcBo}</if>
<if test="ew.entity.dateTime!=null"> AND DATE_TIME=#{ew.entity.dateTime}</if>
<if test="ew.entity.dataField!=null"> AND DATA_FIELD=#{ew.entity.dataField}</if>
<if test="ew.entity.dataAttr!=null"> AND DATA_ATTR=#{ew.entity.dataAttr}</if>
<if test="ew.entity.userBo!=null"> AND USER_BO=#{ew.entity.userBo}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
</if>
</if>
</where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
${ew.sqlSegment}
</if>
</select>
<select id="selectPage" resultMap="BaseResultMap">
SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM SFC_DATA
<where>
<if test="ew!=null">
<if test="ew.entity!=null">
<if test="ew.entity.handle!=null">
HANDLE=#{ew.entity.handle}
</if>
<if test="ew.entity.sfcBo!=null"> AND SFC_BO=#{ew.entity.sfcBo}</if>
<if test="ew.entity.dateTime!=null"> AND DATE_TIME=#{ew.entity.dateTime}</if>
<if test="ew.entity.dataField!=null"> AND DATA_FIELD=#{ew.entity.dataField}</if>
<if test="ew.entity.dataAttr!=null"> AND DATA_ATTR=#{ew.entity.dataAttr}</if>
<if test="ew.entity.userBo!=null"> AND USER_BO=#{ew.entity.userBo}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
</if>
</if>
</where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
${ew.sqlSegment}
</if>
</select>
<select id="selectMapsPage" resultType="HashMap">
SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM SFC_DATA
<where>
<if test="ew!=null">
<if test="ew.entity!=null">
<if test="ew.entity.handle!=null">
HANDLE=#{ew.entity.handle}
</if>
<if test="ew.entity.sfcBo!=null"> AND SFC_BO=#{ew.entity.sfcBo}</if>
<if test="ew.entity.dateTime!=null"> AND DATE_TIME=#{ew.entity.dateTime}</if>
<if test="ew.entity.dataField!=null"> AND DATA_FIELD=#{ew.entity.dataField}</if>
<if test="ew.entity.dataAttr!=null"> AND DATA_ATTR=#{ew.entity.dataAttr}</if>
<if test="ew.entity.userBo!=null"> AND USER_BO=#{ew.entity.userBo}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
</if>
</if>
</where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
${ew.sqlSegment}
</if>
</select>
<insert id="insert" parameterType="com.foreverwin.mesnac.production.model.SfcData">
INSERT INTO SFC_DATA
<trim prefix="(" suffix=")" suffixOverrides=",">
HANDLE,
<if test="sfcBo!=null">SFC_BO,</if>
<if test="dateTime!=null">DATE_TIME,</if>
<if test="dataField!=null">DATA_FIELD,</if>
<if test="dataAttr!=null">DATA_ATTR,</if>
<if test="userBo!=null">USER_BO,</if>
<if test="createdDateTime!=null">CREATED_DATE_TIME,</if>
<if test="modifiedDateTime!=null">MODIFIED_DATE_TIME,</if>
</trim> VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
#{handle},
<if test="sfcBo!=null">#{sfcBo},</if>
<if test="dateTime!=null">#{dateTime},</if>
<if test="dataField!=null">#{dataField},</if>
<if test="dataAttr!=null">#{dataAttr},</if>
<if test="userBo!=null">#{userBo},</if>
<if test="createdDateTime!=null">#{createdDateTime},</if>
<if test="modifiedDateTime!=null">#{modifiedDateTime},</if>
</trim>
</insert>
<insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.production.model.SfcData">
INSERT INTO SFC_DATA
<trim prefix="(" suffix=")" suffixOverrides=",">
<include refid="Base_Column_List"></include>
</trim> VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
#{handle},
#{sfcBo},
#{dateTime},
#{dataField},
#{dataAttr},
#{userBo},
#{createdDateTime},
#{modifiedDateTime},
</trim>
</insert>
<update id="update">
UPDATE SFC_DATA <trim prefix="SET" suffixOverrides=",">
<if test="et.handle!=null">HANDLE=#{et.handle},</if>
<if test="et.sfcBo!=null">SFC_BO=#{et.sfcBo},</if>
<if test="et.dateTime!=null">DATE_TIME=#{et.dateTime},</if>
<if test="et.dataField!=null">DATA_FIELD=#{et.dataField},</if>
<if test="et.dataAttr!=null">DATA_ATTR=#{et.dataAttr},</if>
<if test="et.userBo!=null">USER_BO=#{et.userBo},</if>
<if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if>
<if test="et.modifiedDateTime!=null">MODIFIED_DATE_TIME=#{et.modifiedDateTime},</if>
</trim>
<where>
<if test="ew!=null">
<if test="ew.entity!=null">
HANDLE=#{ew.entity.handle}
<if test="ew.entity.sfcBo!=null"> AND SFC_BO=#{ew.entity.sfcBo}</if>
<if test="ew.entity.dateTime!=null"> AND DATE_TIME=#{ew.entity.dateTime}</if>
<if test="ew.entity.dataField!=null"> AND DATA_FIELD=#{ew.entity.dataField}</if>
<if test="ew.entity.dataAttr!=null"> AND DATA_ATTR=#{ew.entity.dataAttr}</if>
<if test="ew.entity.userBo!=null"> AND USER_BO=#{ew.entity.userBo}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
</if>
</if>
</where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
${ew.sqlSegment}
</if>
</update>
<delete id="deleteByMap">
DELETE FROM SFC_DATA
<if test="cm!=null and !cm.isEmpty">
<where>
<foreach collection="cm.keys" item="k" separator="AND">
<if test="cm[k] != null">
${k} = #{cm[${k}]}
</if>
</foreach>
</where>
</if>
</delete>
<delete id="delete">
DELETE FROM SFC_DATA
<where>
<if test="ew!=null">
<if test="ew.entity!=null">
<if test="ew.entity.handle!=null">
HANDLE=#{ew.entity.handle}
</if>
<if test="ew.entity.sfcBo!=null"> AND SFC_BO=#{ew.entity.sfcBo}</if>
<if test="ew.entity.dateTime!=null"> AND DATE_TIME=#{ew.entity.dateTime}</if>
<if test="ew.entity.dataField!=null"> AND DATA_FIELD=#{ew.entity.dataField}</if>
<if test="ew.entity.dataAttr!=null"> AND DATA_ATTR=#{ew.entity.dataAttr}</if>
<if test="ew.entity.userBo!=null"> AND USER_BO=#{ew.entity.userBo}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
</if>
</if>
</where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
${ew.sqlSegment}
</if>
</delete>
<!-- BaseMapper标准查询/修改/删除 -->
</mapper>
Loading…
Cancel
Save