Browse Source

生产出入库修改

master
shenzhouyu 12 months ago
parent
commit
631a293a92
  1. 43
      src/main/java/com/gaotao/modules/api/service/impl/IfsApiIssueAndReturnServiceImpl.java
  2. 2
      src/main/java/com/gaotao/modules/production/dao/ProductionReturnMapper.java
  3. 4
      src/main/java/com/gaotao/modules/production/service/ProductionIssueService.java
  4. 65
      src/main/java/com/gaotao/modules/production/service/impl/ProductionIssueServiceImpl.java
  5. 10
      src/main/java/com/gaotao/modules/production/service/impl/ProductionReturnServiceImpl.java
  6. 10
      src/main/resources/mapper/production/ProductionReturnMapper.xml

43
src/main/java/com/gaotao/modules/api/service/impl/IfsApiIssueAndReturnServiceImpl.java

@ -15,6 +15,9 @@ import com.gaotao.modules.notify.entity.vo.ShopOrderVo;
import com.gaotao.modules.other.entity.OtherTransactionIfsDto;
import com.gaotao.modules.production.entity.vo.IssueForShopOrderVo;
import jakarta.transaction.Transactional;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@ -22,6 +25,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Service
public class IfsApiIssueAndReturnServiceImpl implements IfsApiIssueAndReturnService {
@ -32,6 +36,8 @@ public class IfsApiIssueAndReturnServiceImpl implements IfsApiIssueAndReturnServ
@Value("${custom.ifs-domainUserID}")
private String domainUserID;
private Logger logger = LogManager.getLogger(getClass());
@Override
public List<InventoryPartVo> getInventoryPart(String partNo, String site){
try{
@ -154,7 +160,12 @@ public class IfsApiIssueAndReturnServiceImpl implements IfsApiIssueAndReturnServ
ObjectMapper objectMapper = new ObjectMapper();
String jsonBody = objectMapper.writeValueAsString(params);
String ifsResponse = HttpUtils.doPost(ifsUrl+"ShopOrderManualIssue",jsonBody,null);
if ("IFSUpdated".equals(ifsResponse) || "\"IFSUpdated\"".equals(ifsResponse)){
logger.info("IFS发料成功");
}else{
logger.info("IFS发料成功"+ifsResponse);
throw new Exception("IFS发料失败");
}
return ifsResponse;
}catch (Exception e){
e.printStackTrace();
@ -190,11 +201,16 @@ public class IfsApiIssueAndReturnServiceImpl implements IfsApiIssueAndReturnServ
String jsonBody = objectMapper.writeValueAsString(params);
System.out.println(jsonBody);
String ifsResponse = HttpUtils.doPost(ifsUrl+"ShopOrderManualUnIssue",jsonBody,null);
if ("IFSUpdated".equals(ifsResponse) || "\"IFSUpdated\"".equals(ifsResponse)){
logger.info("IFS退料成功");
}else{
logger.info("IFS退料失败"+ifsResponse);
throw new Exception("IFS退料失败");
}
return ifsResponse;
}catch (Exception e){
e.printStackTrace();
throw new XJException("领料出库同步IFS失败");
throw new XJException("退料同步IFS失败");
}
}
@ -264,7 +280,12 @@ public class IfsApiIssueAndReturnServiceImpl implements IfsApiIssueAndReturnServ
ObjectMapper objectMapper = new ObjectMapper();
String jsonBody = objectMapper.writeValueAsString(params);
String ifsResponse = HttpUtils.doPost(ifsUrl+"MaterialRequisitionReserve",jsonBody,null);
if ("IFSUpdated".equals(ifsResponse) || "\"IFSUpdated\"".equals(ifsResponse)){
logger.info("MR预留数量成功");
}else{
logger.info("MR预留数量失败"+ifsResponse);
throw new Exception("MR预留数量失败");
}
return ifsResponse;
}catch (Exception e){
e.printStackTrace();
@ -295,7 +316,12 @@ public class IfsApiIssueAndReturnServiceImpl implements IfsApiIssueAndReturnServ
ObjectMapper objectMapper = new ObjectMapper();
String jsonBody = objectMapper.writeValueAsString(params);
String ifsResponse = HttpUtils.doPost(ifsUrl+"MaterialRequisitionIssue",jsonBody,null);
if ("IFSUpdated".equals(ifsResponse) || "\"IFSUpdated\"".equals(ifsResponse)){
logger.info("MR发料成功");
}else{
logger.info("MR发料失败"+ifsResponse);
throw new Exception("MR发料失败");
}
return ifsResponse;
}catch (Exception e){
e.printStackTrace();
@ -415,7 +441,12 @@ public class IfsApiIssueAndReturnServiceImpl implements IfsApiIssueAndReturnServ
ObjectMapper objectMapper = new ObjectMapper();
String jsonBody = objectMapper.writeValueAsString(params);
String ifsResponse = HttpUtils.doPost(ifsUrl+"MaterialRequisitionUnIssue",jsonBody,null);
if ("IFSUpdated".equals(ifsResponse) || "\"IFSUpdated\"".equals(ifsResponse)){
logger.info("MR退料成功");
}else{
logger.info("MR退料失败"+ifsResponse);
throw new Exception("MR退料失败");
}
return ifsResponse;
}catch (Exception e){
e.printStackTrace();

2
src/main/java/com/gaotao/modules/production/dao/ProductionReturnMapper.java

@ -19,4 +19,6 @@ public interface ProductionReturnMapper {
List<UnissueNotifyOrderMaterialList> getUnissueNotifyHeaderOrderMaterialList(@Param("notifyNo") String notifyNo,@Param("site") String site,@Param("itemNo") BigDecimal itemNo);
HandlingUnit scanMaterialLabel(@Param("labelCode") String labelCode, @Param("site") String site,@Param("batchNo") String batchNo,@Param("partNo") String partNo);
void updateHandingUnit(List<HandlingUnit> handlingUnits);
}

4
src/main/java/com/gaotao/modules/production/service/ProductionIssueService.java

@ -24,12 +24,12 @@ public interface ProductionIssueService {
/**
* 获取工单BOM物料列表直接发料
*/
List<ShopOrderMaterialVo> getWorkOrderMaterials(String workOrderNo, String site);
List<ShopOrderMaterialVo> getWorkOrderMaterials(String workOrderNo, String site)throws Exception;
/**
* 直接发料
*/
void directIssue(DirectIssueDto directIssueDto);
void directIssue(DirectIssueDto directIssueDto)throws Exception;
/**
* 获取申请单物料列表基于申请单发料

65
src/main/java/com/gaotao/modules/production/service/impl/ProductionIssueServiceImpl.java

@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.gaotao.common.exception.XJException;
import com.gaotao.common.utils.HttpUtils;
import com.gaotao.modules.api.entity.issueAndReturnVo.IssueShopOrderDto;
import com.gaotao.modules.api.entity.issueAndReturnVo.MaterialRequisitionVo;
import com.gaotao.modules.api.service.IfsApiIssueAndReturnService;
import com.gaotao.modules.handlingunit.entity.HandlingUnit;
import com.gaotao.modules.notify.entity.SOIssueNotifyHeader;
@ -26,6 +27,7 @@ import com.gaotao.modules.trans.service.TransNoControlService;
import com.gaotao.modules.handlingunit.service.HandlingUnitService;
import com.gaotao.modules.warehouse.service.InventoryStockService;
import io.jsonwebtoken.lang.Maps;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@ -38,6 +40,7 @@ import java.util.stream.Collectors;
/**
* 生产发料服务实现
*/
@Slf4j
@Service
public class ProductionIssueServiceImpl implements ProductionIssueService {
@ -81,57 +84,29 @@ public class ProductionIssueServiceImpl implements ProductionIssueService {
@Override
public List<ShopOrderVo> getWorkOrderInfo(String workOrderNo, String site) throws Exception{
Map<String, Object> params = Map.of(
"ifsDBName", ifsDBName,
"domainUserID", domainUserID,
"ifsSiteID", site,
"ifsOrderNo", workOrderNo,
"ifsReleaseNo", "*",
"ifsSequenceNo", "*"
);
ObjectMapper objectMapper = new ObjectMapper();
String jsonBody = objectMapper.writeValueAsString(params);
String ifsResponse = HttpUtils.doGetWithBody(ifsUrl+"ShopOrder",jsonBody,null);
ObjectMapper mapper = new ObjectMapper();
List<ShopOrderVo> shopOrderVos = mapper.readValue(ifsResponse, new TypeReference<List<ShopOrderVo>>() {
});
List<ShopOrderVo> orderInfo = ifsApiIssueAndReturnService.getWorkOrderInfo(workOrderNo, site, "*", "*");
Set<String> allowedStatuses = new HashSet<>(Arrays.asList("Released", "Reserved", "Started"));
List<ShopOrderVo> shopOrderVos = orderInfo.stream().filter(item -> allowedStatuses.contains(item.getObjstate())).collect(Collectors.toList());
return shopOrderVos;
}
@Override
public List<ShopOrderMaterialVo> getWorkOrderMaterials(String workOrderNo, String site){
public List<ShopOrderMaterialVo> getWorkOrderMaterials(String workOrderNo, String site)throws Exception{
// 验证工单状态
if (!validateWorkOrderStatus(workOrderNo, site)) {
throw new XJException("工单状态不允许发料");
}
try{
Map<String, Object> params = Map.of(
"ifsDBName", ifsDBName,
"domainUserID", domainUserID,
"ifsSiteID", site,
"ifsOrderNo", workOrderNo,
"ifsReleaseNo", "*",
"ifsSequenceNo", "*"
);
ObjectMapper objectMapper = new ObjectMapper();
String jsonBody = objectMapper.writeValueAsString(params);
String ifsResponse = HttpUtils.doGetWithBody(ifsUrl+"ShopOrderMaterial",jsonBody,null);
ObjectMapper mapper = new ObjectMapper();
List<ShopOrderMaterialVo> materialVos = mapper.readValue(ifsResponse, new TypeReference<List<ShopOrderMaterialVo>>() {
});
List<ShopOrderMaterialVo> shopOrderMaterialVos = materialVos.stream().filter(m -> "Reserve And Backflush".equals(m.getReserveIssueMethod())).collect(Collectors.toList());
return shopOrderMaterialVos;
}catch (Exception e){
throw new XJException("获取工单BOM物料列表失败: " + e.getMessage());
}
List<ShopOrderMaterialVo> materialVos = ifsApiIssueAndReturnService.getShopOrderMaterial(workOrderNo, site, "*", "*");
List<ShopOrderMaterialVo> shopOrderMaterialVos = materialVos.stream().filter(m -> "Reserve And Backflush".equals(m.getReserveIssueMethod())).collect(Collectors.toList());
return shopOrderMaterialVos;
}
@Override
@Transactional
public void directIssue(DirectIssueDto directIssueDto) {
public void directIssue(DirectIssueDto directIssueDto) throws Exception{
// 验证工单状态
if (!validateWorkOrderStatus(directIssueDto.getWorkOrderNo(), directIssueDto.getSite())) {
throw new XJException("工单状态不允许发料");
@ -157,6 +132,7 @@ public class ProductionIssueServiceImpl implements ProductionIssueService {
transCommonRequestDto.setWorkOrderNo(directIssueDto.getWorkOrderNo());
transCommonRequestDto.setWarehouseId(directIssueDto.getWarehouseId());
Double seqNo = 1.0;
// 处理每个选择的物料
for (WorkOrderMaterialDto material : directIssueDto.getSelectedMaterials()) {
// 验证物料匹配
@ -182,7 +158,8 @@ public class ProductionIssueServiceImpl implements ProductionIssueService {
subDto.setLocationId(material.getLocationId());
subDto.setTransQty(material.getIssueQty().toString());
subDto.setDirection("-");
subDto.setWdrNo(material.getWdrNo());
subDto.setWdrNo(material.getWdrNo() == null?"*":material.getWdrNo());
subDto.setSqeNo(seqNo);
subList.add(subDto);
/*TransDetailDto transDetailDto = new TransDetailDto();
@ -226,6 +203,7 @@ public class ProductionIssueServiceImpl implements ProductionIssueService {
productionIssue.setCreatedDate(new Date());
productionIssue.setIfsStatus("PENDING");
issueList.add(productionIssue);*/
seqNo++;
}
transCommonRequestDto.setSubList(subList);
List<TransDetail> out = transHeaderService.genTransAndChangeInventoryStock(transCommonRequestDto, "OUT");
@ -244,11 +222,12 @@ public class ProductionIssueServiceImpl implements ProductionIssueService {
issueShopOrderDto.setIfsWDRNo(issue.getWdrNo());
issueShopOrderDto.setIfsSerialNo("*");
issueShopOrderDto.setIfsTransQty(issue.getTransQty());
ifsApiIssueAndReturnService.addShopOrderManualIssue(issueShopOrderDto);
String s = ifsApiIssueAndReturnService.addShopOrderManualIssue(issueShopOrderDto);
log.info("IFS发料错误",s);
if (!"IFSUpdated".equals(s)){
throw new Exception("IFS发料失败");
}
}
//TODO 调用打印接口
}
@Override

10
src/main/java/com/gaotao/modules/production/service/impl/ProductionReturnServiceImpl.java

@ -238,5 +238,15 @@ public class ProductionReturnServiceImpl implements ProductionReturnService {
unissueShopOrderDto.setIfsHandlingUnitID("0");
ifsApiIssueAndReturnService.addShopOrderManualUnIssue(unissueShopOrderDto);
}
//前端打印新标签并跟新HandlingUnit的库位和长度
List<HandlingUnit> handlingUnits = new ArrayList<>();
for (WorkOrderMaterialDto material : returnDto.getSelectedMaterials()) {
HandlingUnit hu = new HandlingUnit();
hu.setUnitId(material.getLabelCode());
hu.setLocationId(material.getLocationId());
hu.setQty(material.getIssueQty());
handlingUnits.add(hu);
}
productionReturnMapper.updateHandingUnit(handlingUnits);
}
}

10
src/main/resources/mapper/production/ProductionReturnMapper.xml

@ -35,4 +35,14 @@
from handling_unit a
where a.site=#{site} and a.unit_id=#{labelCode} and a.in_stock_flag='N' and a.batch_no = #{batchNo} and a.part_no = #{partNo}
</select>
<update id="updateHandingUnit" parameterType="java.util.List">
<foreach collection="list" item="hu" separator=";">
UPDATE handling_unit
SET
location_id = #{hu.locationId},
qty = #{hu.qty},
modified_date = GETDATE()
WHERE unit_id = #{hu.unitId}
</foreach>
</update>
</mapper>
Loading…
Cancel
Save