philip 4 years ago
parent 9e2fda10ac
commit fd818a5a37

@ -45,8 +45,7 @@ public class InspectionItemController {
}
@PostMapping("/saveAll")
public R saveAll(@RequestBody InspectionItem inspectionItem){
inspectionItemService.saveAll(inspectionItem);
return R.ok();
return R.ok(inspectionItemService.saveAll(inspectionItem));
}
@GetMapping("/queryAll")
public R queryAll(InspectionItem inspectionItem){

@ -32,7 +32,7 @@ public interface InspectionItemService extends IService<InspectionItem> {
String inspectItemNoGenerationRules(InspectionItem inspectionItem);
void saveAll(InspectionItem inspectionItem);
InspectionItem saveAll(InspectionItem inspectionItem);
void deleteServece(InspectionItem inspectionItem);

@ -27,4 +27,11 @@ public interface SfcDispatchCommonService {
* @return
*/
SfcDispatchDto findResrceBySfc(SfcDispatchDto sfcDispatch);
/**
*
* @param sfcDispatch
* @return
*/
SfcDispatchDto findSfcDispatchBySfc(SfcDispatchDto sfcDispatch);
}

@ -99,7 +99,7 @@ public class InspectionItemServiceImpl extends ServiceImpl<InspectionItemMapper,
}
@Override
public void saveAll(InspectionItem inspectionItem) {
public InspectionItem saveAll(InspectionItem inspectionItem) {
String site = CommonMethods.getSite();
boolean b = false;
if(StringUtil.isEmpty(inspectionItem.getInspectionItemNo())&&inspectionItem.getInspectionItemAdditionList()==null){
@ -207,6 +207,7 @@ public class InspectionItemServiceImpl extends ServiceImpl<InspectionItemMapper,
}
saveOrUpdate(inspectionItem);
}
return inspectionItem;
}
@Override

@ -41,4 +41,6 @@ public interface SfcDispatchMapper extends BaseMapper<SfcDispatch> {
@Param("modifiedDateTime") LocalDateTime modifiedDateTime);
SfcDispatchDto findResrceBySfc(@Param("sfcDispatch")SfcDispatchDto sfcDispatch, @Param("site") String site, @Param("array") String[] array);
SfcDispatchDto findSfcDispatchBySfc(@Param("site")String site, @Param("dto")SfcDispatchDto sfcDispatch);
}

@ -449,6 +449,12 @@ public class SfcDispatchServiceImpl extends ServiceImpl<SfcDispatchMapper, SfcDi
return sfcDispatchMapper.findResrceBySfc(sfcDispatch,site,status);
}
@Override
public SfcDispatchDto findSfcDispatchBySfc(SfcDispatchDto sfcDispatch) {
String site = CommonMethods.getSite();
return sfcDispatchMapper.findSfcDispatchBySfc(site,sfcDispatch);
}
// @Override
// public SfcDispatchDto findResrceBySfc(SfcDispatch sfcDispatch) {
// String site = CommonMethods.getSite();

@ -1096,4 +1096,9 @@
</if>
</where>
</select>
<select id="findSfcDispatchBySfc" resultType="com.foreverwin.mesnac.common.dto.SfcDispatchDto">
SELECT *
FROM Z_SFC_DISPATCH zsd where SFC=#{dto.sfc} AND site=#{dto.site} AND STEP_ID=#{dto.stepId} AND OPERATION=#{dto.operation} AND RESRCE=#{dto.resrce}
</select>
</mapper>

@ -448,7 +448,7 @@
</select>
<select id="selectPage" resultMap="BaseResultMap">
SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Full_Column_List"></include></otherwise></choose>
SELECT item,IT.description,revision
FROM ITEM I
LEFT JOIN ITEM_T IT ON I.HANDLE = IT.ITEM_BO AND IT.LOCALE = 'zh'
<where>

@ -166,7 +166,7 @@
<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}
and ${ew.sqlSegment}
</if>
</if>
</where>

@ -0,0 +1,135 @@
package com.foreverwin.mesnac.production.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.foreverwin.mesnac.meapi.dto.SfcDto;
import com.foreverwin.mesnac.production.model.SfcDataAssemble;
import com.foreverwin.mesnac.production.service.SfcDataAssembleService;
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.*;
import java.util.List;
/**
*
* @author Philip
* @since 2021-07-19
*/
@RestController
@RequestMapping("/Z-SFC-DATA-ASSEMBLE")
public class SfcDataAssembleController {
@Autowired
public SfcDataAssembleService sfcDataAssembleService;
/**
* sfc
* @param sfcDto
* @return
*/
@ResponseBody
@GetMapping("/loadSfcAssemble")
public R loadSfcAssemble(SfcDto sfcDto) {
return R.ok(sfcDataAssembleService.loadSfcAssemble(sfcDto));
}
/**
* id
*
* @param id
* @return
*/
@ResponseBody
@GetMapping("/{id:.+}")
public R getSfcDataAssembleById(@PathVariable String id) {
return R.ok( sfcDataAssembleService.getById(id));
}
/**
*
*
* @return
*/
@ResponseBody
@GetMapping("")
public R getSfcDataAssembleList(SfcDataAssemble sfcDataAssemble){
List<SfcDataAssemble> result;
QueryWrapper<SfcDataAssemble> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(sfcDataAssemble);
result = sfcDataAssembleService.list(queryWrapper);
return R.ok(result);
}
/**
*
*
* @param frontPage
* @return
*/
@ResponseBody
@GetMapping("/page")
public R page(FrontPage<SfcDataAssemble> frontPage, SfcDataAssemble sfcDataAssemble){
IPage result;
QueryWrapper<SfcDataAssemble> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(sfcDataAssemble);
if (frontPage.getGlobalQuery() != null && !"".equals(frontPage.getGlobalQuery().trim())) {
//TODO modify global query
queryWrapper.lambda().and(wrapper -> wrapper
.like(SfcDataAssemble::getHandle, frontPage.getGlobalQuery())
.or().like(SfcDataAssemble::getSite, frontPage.getGlobalQuery())
.or().like(SfcDataAssemble::getSfcDispatchBo, frontPage.getGlobalQuery())
.or().like(SfcDataAssemble::getStatus, frontPage.getGlobalQuery())
.or().like(SfcDataAssemble::getInventoryBo, frontPage.getGlobalQuery())
.or().like(SfcDataAssemble::getItemBo, frontPage.getGlobalQuery())
.or().like(SfcDataAssemble::getCreatedUser, frontPage.getGlobalQuery())
.or().like(SfcDataAssemble::getModifyUser, frontPage.getGlobalQuery())
);
}
result = sfcDataAssembleService.page(frontPage.getPagePlus(), queryWrapper);
return R.ok(result);
}
/**
*
* @param sfcDataAssemble
* @return null
*/
@PostMapping
public R save(@RequestBody SfcDataAssemble sfcDataAssemble) {
return R.ok(sfcDataAssembleService.save(sfcDataAssemble));
}
/**
*
* @param sfcDataAssemble
* @return null
*/
@PutMapping
public R updateById(@RequestBody SfcDataAssemble sfcDataAssemble) {
return R.ok(sfcDataAssembleService.updateById(sfcDataAssemble));
}
/**
* id
* @param id ID
* @return 0 1
*/
@ResponseBody
@RequestMapping(method = RequestMethod.DELETE, value = "/{id:.+}")
public R removeById(@PathVariable("id") String id){
return R.ok(sfcDataAssembleService.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(sfcDataAssembleService.removeByIds(ids));
}
}

@ -65,7 +65,7 @@ public interface SfcCrossMapper extends BaseMapper {
Map<String, Object> getSfcInfo(@Param("site")String site, @Param("sfc")String sfc, @Param("operation")String operation);
Integer getSfcDispatch(@Param("site") String site, @Param("sfc") String sfc, @Param("operation") String operation, @Param("stepId") String stepId,@Param("resrce")String resrce);
String getSfcDispatch(@Param("site") String site, @Param("sfc") String sfc, @Param("operation") String operation, @Param("stepId") String stepId,@Param("resrce")String resrce);
List<SfcDto> getSfcListByResrce(@Param("site") String site, @Param("resrce") String resrce,@Param("locale") String locale);

@ -0,0 +1,69 @@
package com.foreverwin.mesnac.production.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.foreverwin.mesnac.production.model.SfcDataAssemble;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
* <p>
* Mapper
* </p>
*
* @author Philip
* @since 2021-07-19
*/
@Repository
public interface SfcDataAssembleMapper extends BaseMapper<SfcDataAssemble> {
/**
*
* @param sfcDispatchBo BO
* @return
*/
List<Map<String, Object>> querySfcAssemble(@Param("sfcDispatchBo") String sfcDispatchBo);
/**
*
* @param site
* @param sfc
* @param inventoryId
* @param itemBo
* @return
*/
List<Map<String, Object>> queryAssembleDate(@Param("site") String site, @Param("sfc") String sfc, @Param("inventoryId") String inventoryId, @Param("itemBo") String itemBo);
/**
*
* @param handle
* @return
*/
List<Map<String, Object>> sfcAssembleDate(@Param("handle") String handle);
/**
*
* @param
* @return
*/
List<Map<String, Object>> validateSfcAssemble(@Param(value = "site") String site, @Param(value = "inventoryId") String inventoryId, @Param(value = "handle") String handle);
/**
*
* @param handle
* @return
*/
Map<String, Object> querySfcDismantling(@Param("handle") String handle);
List<Map<String, Object>> selectInventoryAnomaly(@Param("site") String site, @Param("inventory") String inventory);
List<Map<String, Object>> selectSfcBomComponent(@Param("sfcDataMainBo") String sfcDataMainBo, @Param("sfcBo") String sfcBo, @Param("stepId") String stepId, @Param("item") String item);
/**
* sfc
* @param site
* @param sfcorinv
* @return
*/
List<Map<String, Object>> queryDrawBySfcOrInv(@Param("site") String site, @Param("sfcorinv") String sfcorinv);
}

@ -0,0 +1,233 @@
package com.foreverwin.mesnac.production.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* <p>
*
* </p>
*
* @author Philip
* @since 2021-07-19
*/
@TableName("Z_SFC_DATA_ASSEMBLE")
public class SfcDataAssemble extends Model<SfcDataAssemble> {
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId(value = "HANDLE", type = IdType.INPUT)
private String handle;
/**
*
*/
@TableField("SITE")
private String site;
/**
*
*/
@TableField("SFC_DISPATCH_BO")
private String sfcDispatchBo;
/**
* A/D/
*/
@TableField("STATUS")
private String status;
/**
* BO
*/
@TableField("INVENTORY_BO")
private String inventoryBo;
/**
*
*/
@TableField("ASSEMBLE_QTY")
private BigDecimal assembleQty;
/**
*
*/
@TableField("ITEM_BO")
private String itemBo;
/**
*
*/
@TableField("CREATED_DATE_TIME")
private LocalDateTime createdDateTime;
/**
*
*/
@TableField("CREATED_USER")
private String createdUser;
/**
*
*/
@TableField("MODIFIED_DATE_TIME")
private LocalDateTime modifiedDateTime;
/**
*
*/
@TableField("MODIFY_USER")
private String modifyUser;
/**
*
*/
@TableField("SEQ")
private Double seq;
public String getHandle() {
return handle;
}
public void setHandle(String handle) {
this.handle = handle;
}
public String getSite() {
return site;
}
public void setSite(String site) {
this.site = site;
}
public String getSfcDispatchBo() {
return sfcDispatchBo;
}
public void setSfcDispatchBo(String sfcDispatchBo) {
this.sfcDispatchBo = sfcDispatchBo;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getInventoryBo() {
return inventoryBo;
}
public void setInventoryBo(String inventoryBo) {
this.inventoryBo = inventoryBo;
}
public BigDecimal getAssembleQty() {
return assembleQty;
}
public void setAssembleQty(BigDecimal assembleQty) {
this.assembleQty = assembleQty;
}
public String getItemBo() {
return itemBo;
}
public void setItemBo(String itemBo) {
this.itemBo = itemBo;
}
public LocalDateTime getCreatedDateTime() {
return createdDateTime;
}
public void setCreatedDateTime(LocalDateTime createdDateTime) {
this.createdDateTime = createdDateTime;
}
public String getCreatedUser() {
return createdUser;
}
public void setCreatedUser(String createdUser) {
this.createdUser = createdUser;
}
public LocalDateTime getModifiedDateTime() {
return modifiedDateTime;
}
public void setModifiedDateTime(LocalDateTime modifiedDateTime) {
this.modifiedDateTime = modifiedDateTime;
}
public String getModifyUser() {
return modifyUser;
}
public void setModifyUser(String modifyUser) {
this.modifyUser = modifyUser;
}
public Double getSeq() {
return seq;
}
public void setSeq(Double seq) {
this.seq = seq;
}
public static final String HANDLE = "HANDLE";
public static final String SITE = "SITE";
public static final String SFC_DISPATCH_BO = "SFC_DISPATCH_BO";
public static final String STATUS = "STATUS";
public static final String INVENTORY_BO = "INVENTORY_BO";
public static final String ASSEMBLE_QTY = "ASSEMBLE_QTY";
public static final String ITEM_BO = "ITEM_BO";
public static final String CREATED_DATE_TIME = "CREATED_DATE_TIME";
public static final String CREATED_USER = "CREATED_USER";
public static final String MODIFIED_DATE_TIME = "MODIFIED_DATE_TIME";
public static final String MODIFY_USER = "MODIFY_USER";
public static final String SEQ = "SEQ";
@Override
protected Serializable pkVal() {
return this.handle;
}
@Override
public String toString() {
return "SfcDataAssemble{" +
"handle = " + handle +
", site = " + site +
", sfcDispatchBo = " + sfcDispatchBo +
", status = " + status +
", inventoryBo = " + inventoryBo +
", assembleQty = " + assembleQty +
", itemBo = " + itemBo +
", createdDateTime = " + createdDateTime +
", createdUser = " + createdUser +
", modifiedDateTime = " + modifiedDateTime +
", modifyUser = " + modifyUser +
", seq = " + seq +
"}";
}
}

@ -15,4 +15,5 @@ public interface PodTemplateService {
void sfcStart(Map<String, Object> map);
void sfcComplete(Map<String, Object> map);
}

@ -0,0 +1,35 @@
package com.foreverwin.mesnac.production.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.foreverwin.mesnac.meapi.dto.SfcDto;
import com.foreverwin.mesnac.production.model.SfcDataAssemble;
import com.baomidou.mybatisplus.extension.service.IService;
import com.foreverwin.modular.core.exception.BaseException;
import com.foreverwin.modular.core.util.FrontPage;
import java.util.List;
import java.util.Map;
/**
* <p>
*
* </p>
*
* @author Philip
* @since 2021-07-19
*/
public interface SfcDataAssembleService extends IService<SfcDataAssemble> {
/**
*
* @param frontPage
* @return
*/
IPage<SfcDataAssemble> selectPage(FrontPage<SfcDataAssemble> frontPage, SfcDataAssemble sfcDataAssemble);
List<SfcDataAssemble> selectList(SfcDataAssemble sfcDataAssemble);
Object loadSfcAssemble(SfcDto sfcDto);
Map<String, Object> assembleInventory(Map<String, Object> paramMap) throws BaseException;
}

@ -111,8 +111,8 @@ public class PodTemplateServiceImpl implements PodTemplateService {
throw new BaseException("产品条码"+sfc+"在"+operationBySfcBo.getOperation()+"/"+operationBySfcBo.getDescription()+"工序");
}*/
//校验SFC+工序+设备+STEP_ID是否与当前设备确认的派工单匹配
Integer integer = sfcCrossMapper.getSfcDispatch(site, sfc, operationBySfcBo.getOperation(), operationBySfcBo.getStepId(), resrce);
if (integer < 1) {
String sfcDispatchStatus = sfcCrossMapper.getSfcDispatch(site, sfc, operationBySfcBo.getOperation(), operationBySfcBo.getStepId(), resrce);
if (StringUtil.isBlank(sfcDispatchStatus)) {
throw new BaseException("产品条码与当前设备工序确认的派工单不匹配");
}
@ -248,6 +248,7 @@ public class PodTemplateServiceImpl implements PodTemplateService {
sfcDispatchCommonService.updateSfcDispatchStatus(site,CommonMethods.getUser(),dispatchNo, DispatchStatusEnum.COMPLETE.getCode());
});
}
void senErp() throws RemoteException {
String shopOrder = "SO20210714";
String stepId = "OP001";

@ -0,0 +1,320 @@
package com.foreverwin.mesnac.production.service.impl;
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.common.dto.SfcDispatchDto;
import com.foreverwin.mesnac.common.enums.DispatchStatusEnum;
import com.foreverwin.mesnac.common.enums.HandleEnum;
import com.foreverwin.mesnac.common.service.SfcDispatchCommonService;
import com.foreverwin.mesnac.common.util.ExceptionUtil;
import com.foreverwin.mesnac.meapi.dto.SfcDto;
import com.foreverwin.mesnac.meapi.model.Inventory;
import com.foreverwin.mesnac.meapi.service.InventoryService;
import com.foreverwin.mesnac.meapi.service.OperationService;
import com.foreverwin.mesnac.production.mapper.SfcCrossMapper;
import com.foreverwin.mesnac.production.mapper.SfcDataAssembleMapper;
import com.foreverwin.mesnac.production.model.SfcDataAssemble;
import com.foreverwin.mesnac.production.service.SfcDataAssembleService;
import com.foreverwin.modular.core.exception.BaseException;
import com.foreverwin.modular.core.meext.MEServices;
import com.foreverwin.modular.core.util.CommonMethods;
import com.foreverwin.modular.core.util.FrontPage;
import com.sap.me.inventory.InventoryServiceInterface;
import com.sap.me.inventory.InventoryValidateAndAddRequest;
import com.sap.me.production.AssembleComponentsRequest;
import com.sap.me.production.AssemblyComponent;
import com.sap.me.production.AssemblyDataField;
import com.sap.me.production.AssemblyServiceInterface;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
/**
* <p>
*
* </p>
*
* @author Philip
* @since 2021-07-19
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class SfcDataAssembleServiceImpl extends ServiceImpl<SfcDataAssembleMapper, SfcDataAssemble> implements SfcDataAssembleService {
@Autowired
private SfcDataAssembleMapper sfcDataAssembleMapper;
@Autowired
private SfcCrossMapper sfcCrossMapper;
@Autowired
private SfcDispatchCommonService sfcDispatchCommonService;
@Autowired
private InventoryService inventoryService;
@Autowired
private OperationService operationService;
@Override
public IPage<SfcDataAssemble> selectPage(FrontPage<SfcDataAssemble> frontPage, SfcDataAssemble sfcDataAssemble) {
QueryWrapper<SfcDataAssemble> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(sfcDataAssemble);
return super.page(frontPage.getPagePlus(), queryWrapper);
}
@Override
public List<SfcDataAssemble> selectList(SfcDataAssemble sfcDataAssemble) {
QueryWrapper<SfcDataAssemble> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(sfcDataAssemble);
return super.list(queryWrapper);
}
@Override
public Object loadSfcAssemble(SfcDto sfcDto) {
//构造参数
String site = CommonMethods.getSite();
String user = CommonMethods.getUser();
String sfc = sfcDto.getSfc();
String operation = sfcDto.getOperation();
String resrce = sfcDto.getResrce();
String workCenter = sfcDto.getWorkCenter();
String stepId = sfcDto.getStepId();
SfcDispatchDto sfcDispatchDto=new SfcDispatchDto();
sfcDispatchDto.setSfc(sfc);
sfcDispatchDto.setStepId(stepId);
sfcDispatchDto.setResrce(resrce);
sfcDispatchDto.setOperation(operation);
SfcDispatchDto sfcDispatchBySfc = sfcDispatchCommonService.findSfcDispatchBySfc(sfcDispatchDto);
if(sfcDispatchBySfc==null||!sfcDispatchBySfc.getDispatchStatus().equals(DispatchStatusEnum.START)){
throw new BaseException("未在生产操作面板中执行开始操作!");
}
Map<String, Object> resultMap = new HashMap<String, Object>();
//查询装配数据
List<Map<String, Object>> assembleList = sfcDataAssembleMapper.querySfcAssemble(sfcDispatchBySfc.getHandle());
resultMap.put("ASSEMBLE_LIST", assembleList);
return resultMap;
}
@Override
public Map<String, Object> assembleInventory(Map<String, Object> paramMap) throws BaseException {
String site = (String) paramMap.get("SITE");
String user = (String) paramMap.get("USER");
String inventoryId = (String) paramMap.get("INVENTORY_ID");
String sfcDispatchBo = (String) paramMap.get("SFC_DATA_MAIN_BO");
String sfc = (String) paramMap.get("SFC");
String barCode = inventoryId;
SfcDispatchDto sfcDispatch=new SfcDispatchDto();
SfcDispatchDto sfcDataMain = sfcDispatchCommonService.findSfcDispatchBySfc(sfcDispatch);
//判断条码是否存在
Inventory inv = inventoryService.getById("InventoryBO:" + site + "," + inventoryId);
/*if(inv.getQtyOnHand() <= 0){
throw new BaseException("物料条码["+inventoryId+"]已无库存数量,无法装配!");
}*/
String[] inventoryIds = null;
if(inv == null){
//一定为拆机,扫描的条码格式为 派工单*步骤标识*物料*SFC*BOM组件顺序
int result1 = inventoryId.indexOf("*");
if (result1 == -1) {
throw new BaseException("物料条码[" + barCode + "]不存在!");
}
inventoryIds = inventoryId.split("\\*");
if (inventoryIds.length != 5) {
throw new BaseException("物料条码[" + barCode + "]不存在!");
}
//判断扫描的条码是否符合
Map<String, Object> sfcDismantling = sfcDataAssembleMapper.querySfcDismantling(sfcDispatchBo);
if(!inventoryIds[0].equals(sfcDismantling.get("DISPATCH_NO")) || !inventoryIds[1].equals(sfcDismantling.get("STEP_ID"))
|| !inventoryIds[3].equals(sfcDismantling.get("SFC"))){
throw new BaseException("物料条码[" + barCode + "]不在装配列表中!");
}
}
//获取需装配数据,判断是为拆机还是装配
List<Map<String, Object>> assembleList = sfcDataAssembleMapper.querySfcAssemble(sfcDispatchBo);
String isFlag = "N";//是否在装配列表中
String isAssemble = "";//装配情况按颜色区分GREEN已装配/拆机完成YELLOW未装配/拆机完成WHITE未进行装配/拆机完成
String item = "";//物料
String isDismantling = "N";//是否为拆机
String itemBo = "";
String bomCompBo = "";
double seq = 0;
BigDecimal qty = BigDecimal.ZERO;
BigDecimal assembleQty = BigDecimal.ZERO;
//for循环判断是否为拆机
for(int i = 0; i < assembleList.size(); i++){
if(inv != null && assembleList.get(i).get("ITEM_BO").equals(inv.getItemBo())){
//为装配或拆机
isDismantling = (String) assembleList.get(i).get("IS_DISMANTLING");
isFlag = "Y";
}else if(inv == null && HandleEnum.ITEM.getPart((String) assembleList.get(i).get("ITEM_BO"),1).equals(inventoryIds[2])
&& "Y".equals(assembleList.get(i).get("IS_DISMANTLING"))){
//一定为拆机
isFlag = "Y";
isDismantling = "Y";
}
}
if(isFlag.equals("N")){
throw new BaseException("物料条码["+barCode+"]不在装配列表中!");
}
//条码不存在且为装配组件提示报错
if(inv == null && "N".equals(isDismantling)){
throw new BaseException("物料条码["+barCode+"]不存在!");
}
//for循环构造数据
isFlag = "N";
for(int i = 0; i < assembleList.size(); i++){
if("N".equals(isDismantling)) {
//装配
if (assembleList.get(i).get("ITEM_BO").equals(inv.getItemBo())) {
isFlag = "Y";
qty = (new BigDecimal(String.valueOf(assembleList.get(i).get("QTY"))));
assembleQty = (new BigDecimal(String.valueOf(assembleList.get(i).get("ASSEMBLE_QTY"))));
item = (String) assembleList.get(i).get("ITEM");
isAssemble = (String) assembleList.get(i).get("IS_ASSEMBLE");
seq = (new BigDecimal(String.valueOf(assembleList.get(i).get("SEQ")))).doubleValue();
itemBo = (String) assembleList.get(i).get("ITEM_BO");
bomCompBo = (String) assembleList.get(i).get("BOM_COMPONENT_BO");
}
}else{
//拆机
if(inv != null){
//条码存在
throw new BaseException("物料条码["+barCode+"]已被拆机,无法再次进行拆机!");
}else{
if(HandleEnum.ITEM.getPart((String) assembleList.get(i).get("ITEM_BO"),1).equals(inventoryIds[2]) && inventoryIds[4].equals(String.valueOf(assembleList.get(i).get("SEQ")))){
isFlag = "Y";
qty = (new BigDecimal(String.valueOf(assembleList.get(i).get("QTY"))));
assembleQty = (new BigDecimal(String.valueOf(assembleList.get(i).get("ASSEMBLE_QTY"))));
item = (String) assembleList.get(i).get("ITEM");
isAssemble = (String) assembleList.get(i).get("IS_ASSEMBLE");
seq = (new BigDecimal(String.valueOf(assembleList.get(i).get("SEQ")))).doubleValue();
itemBo = (String) assembleList.get(i).get("ITEM_BO");
bomCompBo = (String) assembleList.get(i).get("BOM_COMPONENT_BO");
}
}
}
}
if(isFlag.equals("N")){
throw new BaseException("物料条码["+barCode+"]不在装配列表中!");
}
if(isAssemble.equals("GREEN")){
String dismantlingDesc = "N".equals(isDismantling) ? "装配" : "拆机";
throw new BaseException("物料["+item+"]已"+ dismantlingDesc +"完成,无需再进行"+ dismantlingDesc +"");
}
//装配
if("N".equals(isDismantling)) {
if(inv.getQtyOnHand().doubleValue() <= 0){
throw new BaseException("物料条码["+barCode+"]已无库存数量,无法装配!");
}
//校验
List<Map<String, Object>> validateList = sfcDataAssembleMapper.validateSfcAssemble(site, inventoryId, sfcDispatchBo);
if (validateList.size() > 0) {
for (int i = 0; i < validateList.size(); i++) {
Map<String, Object> validateMap = validateList.get(i);
String statusMess = (String) validateMap.get("STATUS_MESS");
String status = statusMess.substring(0, 1);
if ("N".equals(status)) {
String mess = statusMess.substring(2, statusMess.length());
throw new BaseException(mess);
}
}
}
//物料消耗,添加装配数据,无需扣减库存
BigDecimal qtyOnHand = BigDecimal.ZERO;
if (inv.getQtyOnHand().subtract (qty.subtract(assembleQty) ).doubleValue() > 0) {
qtyOnHand = inv.getQtyOnHand() .subtract (qty.subtract(assembleQty));
}
BigDecimal assembleSfcQty = inv.getQtyOnHand() .subtract(qtyOnHand) ;
//inv.setQtyOnHand(qtyOnHand);
//inventoryService.saveOrUpdate(inv);
//标准物料消耗
AssembleComponentsRequest assembleComponentsRequest = new AssembleComponentsRequest();
List<AssemblyComponent> componentList = new ArrayList<AssemblyComponent>();
List<AssemblyDataField> adf = new ArrayList<AssemblyDataField>();
AssemblyComponent ac = new AssemblyComponent();
String[] str = {"INVENTORY_ID_SFC", "SLOT_QTY"};
for (int j = 0; j < str.length; j++) {
AssemblyDataField ad = new AssemblyDataField();
ad.setAttribute(str[j]);
String value = inv.getInventoryId();
if ("SLOT_QTY".equals(str[j])) {
value = String.valueOf(assembleSfcQty);
}
ad.setValue(value);
adf.add(ad);
}
ac.setActualComponentRef(inv.getItemBo());
ac.setTimeBased(false);
ac.setBomComponentRef(bomCompBo);
ac.setAssemblyDataFields(adf);
ac.setQty(assembleSfcQty);
ac.setSetErpSentFlag(false);
componentList.add(ac);
assembleComponentsRequest.setResourceRef("ResourceBO:" + site + "," + sfcDataMain.getResrce());
assembleComponentsRequest.setStepId(sfcDataMain.getStepId());
String operationBo = operationService.getCurrentRevisionRef(site, sfcDataMain.getOperation()).getHandle();
assembleComponentsRequest.setOperationRef(operationBo);
assembleComponentsRequest.setEvent("baseFinished:AssemblyPoint");
assembleComponentsRequest.setComponentList(componentList);
assembleComponentsRequest.setSfcRef("SFCBO:" + site + "," + sfc);
try {
AssemblyServiceInterface assemblyService = null;
assemblyService = MEServices.create("com.sap.me.production", "AssemblyService", site);
assemblyService.assembleComponents(assembleComponentsRequest);
} catch (Exception e) {
ExceptionUtil.throwException(e);
}
SfcDataAssemble assemble = new SfcDataAssemble();
assemble.setHandle("SfcDataAssembleBO:" + site + "," + UUID.randomUUID().toString());
assemble.setSite(site);
assemble.setSfcDispatchBo(sfcDispatchBo);
assemble.setStatus("A");
assemble.setInventoryBo(inv.getHandle());
assemble.setSeq(seq);
assemble.setItemBo(inv.getItemBo());
assemble.setAssembleQty(assembleSfcQty);
assemble.setCreatedUser(user);
assemble.setCreatedDateTime(LocalDateTime.now());
assemble.setModifiedDateTime(LocalDateTime.now());
assemble.setModifyUser(user);
sfcDataAssembleMapper.insert(assemble);
}else{
BigDecimal assembleSfcQty = qty;
//生成库存
InventoryServiceInterface inventoryServiceInterface = null;
try {
inventoryServiceInterface = MEServices.create("com.sap.me.inventory", "InventoryService", site);
} catch (ClassNotFoundException e) {
throw new BaseException(e.getMessage());
}
InventoryValidateAndAddRequest invAddRequest = new InventoryValidateAndAddRequest();
invAddRequest.setInventoryId(inventoryId);
invAddRequest.setQuantityOnHand(assembleSfcQty);
invAddRequest.setItemRef(itemBo);
String shopOrderBo = HandleEnum.SHOP_ORDER.getHandle(site, sfcDataMain.getShopOrder());
invAddRequest.setShopOrderLocationRef(shopOrderBo);
try {
inventoryServiceInterface.validateAndAdd(invAddRequest);
} catch (com.sap.me.frame.domain.BusinessException e) {
ExceptionUtil.throwException( e);
}
}
return null;
}
}

@ -146,8 +146,8 @@ WHERE sfc.site = #{site} and
AND #{operation} = O.OPERATION
WHERE S.SFC=#{sfc} AND S.SITE=#{site}
</select>
<select id="getSfcDispatch" resultType="java.lang.Integer">
SELECT COUNT(HANDLE) FROM Z_SFC_DISPATCH zsd WHERE OPERATION= #{operation} AND SFC= #{sfc} AND STEP_ID= #{stepId} AND SITE= #{site} AND RESRCE=#{resrce}
<select id="getSfcDispatch" resultType="java.lang.String">
SELECT DISPATCH_STATUS FROM Z_SFC_DISPATCH zsd WHERE OPERATION= #{operation} AND SFC= #{sfc} AND STEP_ID= #{stepId} AND SITE= #{site} AND RESRCE=#{resrce}
</select>
<select id="getSfcListByResrce" resultType="com.foreverwin.mesnac.meapi.dto.SfcDto">

@ -0,0 +1,458 @@
<?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.SfcDataAssembleMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.foreverwin.mesnac.production.model.SfcDataAssemble">
<id column="HANDLE" property="handle" />
<result column="SITE" property="site" />
<result column="SFC_DISPATCH_BO" property="sfcDispatchBo" />
<result column="STATUS" property="status" />
<result column="INVENTORY_BO" property="inventoryBo" />
<result column="ASSEMBLE_QTY" property="assembleQty" />
<result column="ITEM_BO" property="itemBo" />
<result column="CREATED_DATE_TIME" property="createdDateTime" />
<result column="CREATED_USER" property="createdUser" />
<result column="MODIFIED_DATE_TIME" property="modifiedDateTime" />
<result column="MODIFY_USER" property="modifyUser" />
<result column="SEQ" property="seq" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
HANDLE, SITE, SFC_DISPATCH_BO, STATUS, INVENTORY_BO, ASSEMBLE_QTY, ITEM_BO, CREATED_DATE_TIME, CREATED_USER, MODIFIED_DATE_TIME, MODIFY_USER, SEQ
</sql>
<!-- BaseMapper标准查询/修改/删除 -->
<select id="selectById" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"></include> FROM Z_SFC_DATA_ASSEMBLE WHERE HANDLE=#{handle}
</select>
<select id="selectByMap" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"></include>
FROM Z_SFC_DATA_ASSEMBLE
<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="selectBatchIds" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"></include>
FROM Z_SFC_DATA_ASSEMBLE WHERE HANDLE IN (
<foreach item="item" index="index" collection="coll" separator=",">#{item}
</foreach>)
</select>
<select id="selectOne" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"></include> FROM Z_SFC_DATA_ASSEMBLE
<where>
<if test="ew.entity.handle!=null">
HANDLE=#{ew.handle}
</if>
<if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
<if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
<if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
<if test="ew.entity.inventoryBo!=null"> AND INVENTORY_BO=#{ew.entity.inventoryBo}</if>
<if test="ew.entity.assembleQty!=null"> AND ASSEMBLE_QTY=#{ew.entity.assembleQty}</if>
<if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
<if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
<if test="ew.entity.seq!=null"> AND SEQ=#{ew.entity.seq}</if>
</where>
</select>
<select id="selectCount" resultType="Integer">
SELECT COUNT(1) FROM Z_SFC_DATA_ASSEMBLE
<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.site!=null"> AND SITE=#{ew.entity.site}</if>
<if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
<if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
<if test="ew.entity.inventoryBo!=null"> AND INVENTORY_BO=#{ew.entity.inventoryBo}</if>
<if test="ew.entity.assembleQty!=null"> AND ASSEMBLE_QTY=#{ew.entity.assembleQty}</if>
<if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
<if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
<if test="ew.entity.seq!=null"> AND SEQ=#{ew.entity.seq}</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 Z_SFC_DATA_ASSEMBLE
<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.site!=null"> AND SITE=#{ew.entity.site}</if>
<if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
<if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
<if test="ew.entity.inventoryBo!=null"> AND INVENTORY_BO=#{ew.entity.inventoryBo}</if>
<if test="ew.entity.assembleQty!=null"> AND ASSEMBLE_QTY=#{ew.entity.assembleQty}</if>
<if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
<if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
<if test="ew.entity.seq!=null"> AND SEQ=#{ew.entity.seq}</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 Z_SFC_DATA_ASSEMBLE
<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.site!=null"> AND SITE=#{ew.entity.site}</if>
<if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
<if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
<if test="ew.entity.inventoryBo!=null"> AND INVENTORY_BO=#{ew.entity.inventoryBo}</if>
<if test="ew.entity.assembleQty!=null"> AND ASSEMBLE_QTY=#{ew.entity.assembleQty}</if>
<if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
<if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
<if test="ew.entity.seq!=null"> AND SEQ=#{ew.entity.seq}</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 Z_SFC_DATA_ASSEMBLE
<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.site!=null"> AND SITE=#{ew.entity.site}</if>
<if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
<if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
<if test="ew.entity.inventoryBo!=null"> AND INVENTORY_BO=#{ew.entity.inventoryBo}</if>
<if test="ew.entity.assembleQty!=null"> AND ASSEMBLE_QTY=#{ew.entity.assembleQty}</if>
<if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
<if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
<if test="ew.entity.seq!=null"> AND SEQ=#{ew.entity.seq}</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 Z_SFC_DATA_ASSEMBLE
<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.site!=null"> AND SITE=#{ew.entity.site}</if>
<if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
<if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
<if test="ew.entity.inventoryBo!=null"> AND INVENTORY_BO=#{ew.entity.inventoryBo}</if>
<if test="ew.entity.assembleQty!=null"> AND ASSEMBLE_QTY=#{ew.entity.assembleQty}</if>
<if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
<if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
<if test="ew.entity.seq!=null"> AND SEQ=#{ew.entity.seq}</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 Z_SFC_DATA_ASSEMBLE
<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.site!=null"> AND SITE=#{ew.entity.site}</if>
<if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
<if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
<if test="ew.entity.inventoryBo!=null"> AND INVENTORY_BO=#{ew.entity.inventoryBo}</if>
<if test="ew.entity.assembleQty!=null"> AND ASSEMBLE_QTY=#{ew.entity.assembleQty}</if>
<if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
<if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
<if test="ew.entity.seq!=null"> AND SEQ=#{ew.entity.seq}</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.SfcDataAssemble">
INSERT INTO Z_SFC_DATA_ASSEMBLE
<trim prefix="(" suffix=")" suffixOverrides=",">
HANDLE,
<if test="site!=null">SITE,</if>
<if test="sfcDispatchBo!=null">SFC_DISPATCH_BO,</if>
<if test="status!=null">STATUS,</if>
<if test="inventoryBo!=null">INVENTORY_BO,</if>
<if test="assembleQty!=null">ASSEMBLE_QTY,</if>
<if test="itemBo!=null">ITEM_BO,</if>
<if test="createdDateTime!=null">CREATED_DATE_TIME,</if>
<if test="createdUser!=null">CREATED_USER,</if>
<if test="modifiedDateTime!=null">MODIFIED_DATE_TIME,</if>
<if test="modifyUser!=null">MODIFY_USER,</if>
<if test="seq!=null">SEQ,</if>
</trim> VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
#{handle},
<if test="site!=null">#{site},</if>
<if test="sfcDispatchBo!=null">#{sfcDispatchBo},</if>
<if test="status!=null">#{status},</if>
<if test="inventoryBo!=null">#{inventoryBo},</if>
<if test="assembleQty!=null">#{assembleQty},</if>
<if test="itemBo!=null">#{itemBo},</if>
<if test="createdDateTime!=null">#{createdDateTime},</if>
<if test="createdUser!=null">#{createdUser},</if>
<if test="modifiedDateTime!=null">#{modifiedDateTime},</if>
<if test="modifyUser!=null">#{modifyUser},</if>
<if test="seq!=null">#{seq},</if>
</trim>
</insert>
<insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.production.model.SfcDataAssemble">
INSERT INTO Z_SFC_DATA_ASSEMBLE
<trim prefix="(" suffix=")" suffixOverrides=",">
<include refid="Base_Column_List"></include>
</trim> VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
#{handle},
#{site},
#{sfcDispatchBo},
#{status},
#{inventoryBo},
#{assembleQty},
#{itemBo},
#{createdDateTime},
#{createdUser},
#{modifiedDateTime},
#{modifyUser},
#{seq},
</trim>
</insert>
<update id="updateById">
UPDATE Z_SFC_DATA_ASSEMBLE <trim prefix="SET" suffixOverrides=",">
<if test="et.site!=null">SITE=#{et.site},</if>
<if test="et.sfcDispatchBo!=null">SFC_DISPATCH_BO=#{et.sfcDispatchBo},</if>
<if test="et.status!=null">STATUS=#{et.status},</if>
<if test="et.inventoryBo!=null">INVENTORY_BO=#{et.inventoryBo},</if>
<if test="et.assembleQty!=null">ASSEMBLE_QTY=#{et.assembleQty},</if>
<if test="et.itemBo!=null">ITEM_BO=#{et.itemBo},</if>
<if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if>
<if test="et.createdUser!=null">CREATED_USER=#{et.createdUser},</if>
<if test="et.modifiedDateTime!=null">MODIFIED_DATE_TIME=#{et.modifiedDateTime},</if>
<if test="et.modifyUser!=null">MODIFY_USER=#{et.modifyUser},</if>
<if test="et.seq!=null">SEQ=#{et.seq},</if>
</trim> WHERE HANDLE=#{et.handle} <if test="et instanceof java.util.Map"><if test="et.MP_OPTLOCK_VERSION_ORIGINAL!=null">and ${et.MP_OPTLOCK_VERSION_COLUMN}=#{et.MP_OPTLOCK_VERSION_ORIGINAL}</if></if>
</update>
<update id="updateAllColumnById">
UPDATE Z_SFC_DATA_ASSEMBLE <trim prefix="SET" suffixOverrides=",">
SITE=#{et.site},
SFC_DISPATCH_BO=#{et.sfcDispatchBo},
STATUS=#{et.status},
INVENTORY_BO=#{et.inventoryBo},
ASSEMBLE_QTY=#{et.assembleQty},
ITEM_BO=#{et.itemBo},
CREATED_DATE_TIME=#{et.createdDateTime},
CREATED_USER=#{et.createdUser},
MODIFIED_DATE_TIME=#{et.modifiedDateTime},
MODIFY_USER=#{et.modifyUser},
SEQ=#{et.seq},
</trim> WHERE HANDLE=#{et.handle} <if test="et instanceof java.util.Map"><if test="et.MP_OPTLOCK_VERSION_ORIGINAL!=null">and ${et.MP_OPTLOCK_VERSION_COLUMN}=#{et.MP_OPTLOCK_VERSION_ORIGINAL}</if></if>
</update>
<update id="update">
UPDATE Z_SFC_DATA_ASSEMBLE <trim prefix="SET" suffixOverrides=",">
<if test="et.site!=null">SITE=#{et.site},</if>
<if test="et.sfcDispatchBo!=null">SFC_DISPATCH_BO=#{et.sfcDispatchBo},</if>
<if test="et.status!=null">STATUS=#{et.status},</if>
<if test="et.inventoryBo!=null">INVENTORY_BO=#{et.inventoryBo},</if>
<if test="et.assembleQty!=null">ASSEMBLE_QTY=#{et.assembleQty},</if>
<if test="et.itemBo!=null">ITEM_BO=#{et.itemBo},</if>
<if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if>
<if test="et.createdUser!=null">CREATED_USER=#{et.createdUser},</if>
<if test="et.modifiedDateTime!=null">MODIFIED_DATE_TIME=#{et.modifiedDateTime},</if>
<if test="et.modifyUser!=null">MODIFY_USER=#{et.modifyUser},</if>
<if test="et.seq!=null">SEQ=#{et.seq},</if>
</trim>
<where>
<if test="ew!=null">
<if test="ew.entity!=null">
HANDLE=#{ew.entity.handle}
<if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
<if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
<if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
<if test="ew.entity.inventoryBo!=null"> AND INVENTORY_BO=#{ew.entity.inventoryBo}</if>
<if test="ew.entity.assembleQty!=null"> AND ASSEMBLE_QTY=#{ew.entity.assembleQty}</if>
<if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
<if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
<if test="ew.entity.seq!=null"> AND SEQ=#{ew.entity.seq}</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="deleteById">
DELETE FROM Z_SFC_DATA_ASSEMBLE WHERE HANDLE=#{handle}
</delete>
<delete id="deleteByMap">
DELETE FROM Z_SFC_DATA_ASSEMBLE
<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 Z_SFC_DATA_ASSEMBLE
<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.site!=null"> AND SITE=#{ew.entity.site}</if>
<if test="ew.entity.sfcDispatchBo!=null"> AND SFC_DISPATCH_BO=#{ew.entity.sfcDispatchBo}</if>
<if test="ew.entity.status!=null"> AND STATUS=#{ew.entity.status}</if>
<if test="ew.entity.inventoryBo!=null"> AND INVENTORY_BO=#{ew.entity.inventoryBo}</if>
<if test="ew.entity.assembleQty!=null"> AND ASSEMBLE_QTY=#{ew.entity.assembleQty}</if>
<if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.createdUser!=null"> AND CREATED_USER=#{ew.entity.createdUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
<if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if>
<if test="ew.entity.seq!=null"> AND SEQ=#{ew.entity.seq}</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>
<delete id="deleteBatchIds">
DELETE FROM Z_SFC_DATA_ASSEMBLE WHERE HANDLE IN (
<foreach item="item" index="index" collection="coll" separator=",">#{item}
</foreach>)
</delete>
<!-- BaseMapper标准查询/修改/删除 -->
<select id="querySfcAssemble" resultType="map">
WITH SFC_DATA AS(
SELECT DA.ITEM_BO,DA.SEQ, SUM(DA.ASSEMBLE_QTY) ASSEMBLE_QTY FROM Z_SFC_DATA_ASSEMBLE DA
WHERE DA.SFC_DISPATCH_BO = #{sfcDispatchBo}
GROUP BY DA.ITEM_BO, DA.SEQ
)
SELECT CASE WHEN CF2.VALUE='Y' THEN N'-' ELSE N'+' END || N'物料:'||I.ITEM||'/'||I.REVISION||N' 数量:'|| S.QTY * BC.QTY ITEM_REVISION,
S.QTY * BC.QTY QTY,NVL(SD.ASSEMBLE_QTY,0) ASSEMBLE_QTY,I.HANDLE ITEM_BO,I.ITEM,IT.DESCRIPTION ITEM_DESC,
CASE WHEN NVL(SD.ASSEMBLE_QTY,0) = 0 THEN 'WHITE'
WHEN NVL(SD.ASSEMBLE_QTY,0) = S.QTY * BC.QTY THEN 'GREEN'
ELSE 'YELLOW' END IS_ASSEMBLE,BC.HANDLE BOM_COMPONENT_BO,
CASE WHEN CF2.VALUE='Y' THEN 'Y' ELSE 'N' END IS_DISMANTLING, BC."SEQUENCE" SEQ
FROM Z_SFC_DISPATCH DM
INNER JOIN SFC S ON S.SITE = DM.SITE AND S.SFC = DM.SFC
INNER JOIN SFC_BOM SB ON SB.SFC_BO = S.HANDLE
INNER JOIN BOM_COMPONENT BC ON BC.BOM_BO = SB.BOM_BO
INNER JOIN ITEM I ON I.HANDLE = BC.COMPONENT_GBO
LEFT JOIN ITEM_T IT ON IT.ITEM_BO = I.HANDLE AND IT.LOCALE ='zh'
INNER JOIN CUSTOM_FIELDS I_CF ON I_CF.HANDLE = I.HANDLE AND I_CF."ATTRIBUTE" = 'ACCESSORY_TYPE' AND I_CF.VALUE ='9'
INNER JOIN BOM_OPERATION BO ON BO.BOM_COMPONENT_BO = BC.HANDLE
AND BO.OPERATION_BO = 'OperationBO:'||S.SITE||','||DM.OPERATION||',#'
INNER JOIN CUSTOM_FIELDS CF ON CF.HANDLE = BC.HANDLE AND CF."ATTRIBUTE" = 'STEP_ID' AND CF.VALUE = DM.STEP_ID
LEFT JOIN SFC_DATA SD ON SD.ITEM_BO = I.HANDLE AND BC."SEQUENCE" = SD.SEQ
WHERE DM.HANDLE = #{sfcDispatchBo}
</select>
</mapper>
Loading…
Cancel
Save