diff --git a/common/src/main/java/com/foreverwin/mesnac/common/config/ActiveMQConfig.java b/common/src/main/java/com/foreverwin/mesnac/common/config/ActiveMQConfig.java new file mode 100644 index 00000000..569df7ec --- /dev/null +++ b/common/src/main/java/com/foreverwin/mesnac/common/config/ActiveMQConfig.java @@ -0,0 +1,60 @@ +package com.foreverwin.mesnac.common.config; + + +import org.apache.activemq.ActiveMQConnectionFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.jms.config.DefaultJmsListenerContainerFactory; +import org.springframework.jms.config.JmsListenerContainerFactory; +import org.springframework.jms.core.JmsMessagingTemplate; + +@Configuration +@ConditionalOnProperty(prefix = "spring.activemq", value = {"enabled"}, matchIfMissing = true) +public class ActiveMQConfig { + + //☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆ + @Primary + @Bean(name = "defaultConnectionFactory") + public ActiveMQConnectionFactory defaultConnectionFactory( + @Value("${spring.activemq.brokerUrl}") String brokerUrl, + @Value("${spring.activemq.user}") String username, + @Value("${spring.activemq.password}") String password) { + + return this.createConnectionFactory(brokerUrl, username, password); + } + + + private ActiveMQConnectionFactory createConnectionFactory (String brokerUrl, String username, String password) { + ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(); + factory.setBrokerURL(brokerUrl); + factory.setUserName(username); + factory.setPassword(password); + return factory; + } + + //************************************************************************************************************** + @Primary + @Bean(name = "defaultJmsTemplate") + public JmsMessagingTemplate defaultJmsTemplate( + @Qualifier("defaultConnectionFactory") ActiveMQConnectionFactory connectionFactory) { + + JmsMessagingTemplate template = new JmsMessagingTemplate(connectionFactory); + return template; + } + + + //☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆ + @Primary + @Bean(name = "defaultFactory") + public JmsListenerContainerFactory defaultFactory( + @Qualifier("defaultConnectionFactory") ActiveMQConnectionFactory connectionFactory) { + + DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory(); + factory.setConnectionFactory(connectionFactory); + return factory; + } +} diff --git a/common/src/main/java/com/foreverwin/mesnac/common/controller/InspectionTaskController.java b/common/src/main/java/com/foreverwin/mesnac/common/controller/InspectionTaskController.java index 9f727651..2e8b71ae 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/controller/InspectionTaskController.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/controller/InspectionTaskController.java @@ -33,7 +33,7 @@ public class InspectionTaskController { @PostMapping("/save") public R getInspectionTaskList(@RequestBody Map paramMap){ inspectionTaskService.saveTask(paramMap); - return R.ok("保存成功"); + return R.ok(null,"保存成功"); } @ResponseBody @RequestMapping(method = RequestMethod.POST, value = "/createTask") diff --git a/console/src/main/resources/application-local.yml b/console/src/main/resources/application-local.yml index 7d58d3c6..b9642b34 100644 --- a/console/src/main/resources/application-local.yml +++ b/console/src/main/resources/application-local.yml @@ -8,6 +8,14 @@ spring: username: wip password: wip driver-class-name: oracle.jdbc.OracleDriver + activemq: + enabled: true + brokerUrl: tcp://localhost:61616?wireFormat.maxInactivityDuration=0 + password: admin + user: admin + pool: + enabled: true + max-connections: 10 mybatis-plus: statement-lazy-load: true diff --git a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/controller/SurplusItemReturnController.java b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/controller/SurplusItemReturnController.java index 22a6c699..5a6b753a 100644 --- a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/controller/SurplusItemReturnController.java +++ b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/controller/SurplusItemReturnController.java @@ -13,6 +13,8 @@ import org.springframework.web.bind.annotation.*; import com.foreverwin.mesnac.dispatch.service.SurplusItemReturnService; import com.foreverwin.mesnac.dispatch.model.SurplusItemReturn; + +import java.math.BigDecimal; import java.util.List; import java.util.Map; @@ -48,4 +50,27 @@ public class SurplusItemReturnController { return R.ok(result); } + @ResponseBody + @GetMapping("/surplusReturn") + public R surplusReturn(String inventory, String length, String width, String qty) { + try { + if (StringUtil.isBlank(inventory)) { + throw BusinessException.build("物料条码不能为空!"); + } + if (StringUtil.isBlank(length) && StringUtil.isBlank(width)) { + throw BusinessException.build("长度和宽度不能同时为空!"); + } + if (StringUtil.isBlank(qty)) { + throw BusinessException.build("数量不能为空!"); + } + + String site = CommonMethods.getSite(); + String user = CommonMethods.getUser(); + surplusItemReturnService.surplusReturn(site, user, inventory, length, width, new BigDecimal(qty)); + } catch (Exception e) { + return R.failed(e.getMessage()); + } + + return R.ok("物料条码【" +inventory+ "】余料退回操作成功!"); + } } \ No newline at end of file diff --git a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/model/SurplusItemReturn.java b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/model/SurplusItemReturn.java index e1205e64..99b99826 100644 --- a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/model/SurplusItemReturn.java +++ b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/model/SurplusItemReturn.java @@ -5,6 +5,8 @@ import java.io.Serializable; import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.extension.activerecord.Model; import com.baomidou.mybatisplus.annotation.TableId; + +import java.math.BigDecimal; import java.time.LocalDateTime; import com.baomidou.mybatisplus.annotation.TableField; import java.io.Serializable; @@ -20,7 +22,6 @@ import com.baomidou.mybatisplus.annotation.IdType; */ @TableName("Z_SURPLUS_ITEM_RETURN") - public class SurplusItemReturn extends Model { private static final long serialVersionUID = 1L; @@ -54,22 +55,22 @@ public class SurplusItemReturn extends Model { * 余料长度 */ @TableField("LENGHT") - private Double lenght; + private String lenght; /** * 余料宽度 */ @TableField("WIDTH") - private Double width; + private String width; /** * 余料数量 */ @TableField("QTY") - private Double qty; + private BigDecimal qty; /** * 创建用户 */ - @TableField("CREATE_USER_BO") - private String createUserBo; + @TableField("CREATE_USER") + private String createUser; /** * 创建时间 */ @@ -78,13 +79,13 @@ public class SurplusItemReturn extends Model { /** * 更新用户 */ - @TableField("UPDATE_USER_BO") - private String updateUserBo; + @TableField("MODIFU_USER") + private String modifuUser; /** * 更新时间 */ - @TableField("UPDATED_DATE_TIME") - private LocalDateTime updatedDateTime; + @TableField("MODIFIED_DATE_TIME") + private LocalDateTime modifiedDateTime; public String getHandle() { @@ -127,36 +128,36 @@ public class SurplusItemReturn extends Model { this.itemBo = itemBo; } - public Double getLenght() { + public String getLenght() { return lenght; } - public void setLenght(Double lenght) { + public void setLenght(String lenght) { this.lenght = lenght; } - public Double getWidth() { + public String getWidth() { return width; } - public void setWidth(Double width) { + public void setWidth(String width) { this.width = width; } - public Double getQty() { + public BigDecimal getQty() { return qty; } - public void setQty(Double qty) { + public void setQty(BigDecimal qty) { this.qty = qty; } - public String getCreateUserBo() { - return createUserBo; + public String getCreateUser() { + return createUser; } - public void setCreateUserBo(String createUserBo) { - this.createUserBo = createUserBo; + public void setCreateUser(String createUser) { + this.createUser = createUser; } public LocalDateTime getCreatedDateTime() { @@ -167,20 +168,20 @@ public class SurplusItemReturn extends Model { this.createdDateTime = createdDateTime; } - public String getUpdateUserBo() { - return updateUserBo; + public String getModifuUser() { + return modifuUser; } - public void setUpdateUserBo(String updateUserBo) { - this.updateUserBo = updateUserBo; + public void setModifuUser(String modifuUser) { + this.modifuUser = modifuUser; } - public LocalDateTime getUpdatedDateTime() { - return updatedDateTime; + public LocalDateTime getModifiedDateTime() { + return modifiedDateTime; } - public void setUpdatedDateTime(LocalDateTime updatedDateTime) { - this.updatedDateTime = updatedDateTime; + public void setModifiedDateTime(LocalDateTime modifiedDateTime) { + this.modifiedDateTime = modifiedDateTime; } public static final String HANDLE = "HANDLE"; @@ -199,13 +200,13 @@ public static final String WIDTH = "WIDTH"; public static final String QTY = "QTY"; -public static final String CREATE_USER_BO = "CREATE_USER_BO"; +public static final String CREATE_USER = "CREATE_USER"; public static final String CREATED_DATE_TIME = "CREATED_DATE_TIME"; -public static final String UPDATE_USER_BO = "UPDATE_USER_BO"; +public static final String MODIFU_USER = "MODIFU_USER"; -public static final String UPDATED_DATE_TIME = "UPDATED_DATE_TIME"; +public static final String MODIFIED_DATE_TIME = "MODIFIED_DATE_TIME"; @Override @@ -224,10 +225,10 @@ public static final String UPDATED_DATE_TIME = "UPDATED_DATE_TIME"; ", lenght = " + lenght + ", width = " + width + ", qty = " + qty + - ", createUserBo = " + createUserBo + + ", createUser = " + createUser + ", createdDateTime = " + createdDateTime + - ", updateUserBo = " + updateUserBo + - ", updatedDateTime = " + updatedDateTime + + ", modifuUser = " + modifuUser + + ", modifiedDateTime = " + modifiedDateTime + "}"; } } \ No newline at end of file diff --git a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/SurplusItemReturnService.java b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/SurplusItemReturnService.java index 808ff269..d863294b 100644 --- a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/SurplusItemReturnService.java +++ b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/SurplusItemReturnService.java @@ -3,6 +3,7 @@ package com.foreverwin.mesnac.dispatch.service; import com.foreverwin.mesnac.dispatch.model.SurplusItemReturn; import com.baomidou.mybatisplus.extension.service.IService; +import java.math.BigDecimal; import java.util.Map; /** @@ -26,4 +27,16 @@ public interface SurplusItemReturnService extends IService { * @return */ Map getInventoryData(String site, String inventory); + + /** + * 余料退回 + * + * @param site + * @param user + * @param inventory + * @param length + * @param width + * @param qty + */ + void surplusReturn(String site, String user, String inventory, String length, String width, BigDecimal qty); } \ No newline at end of file diff --git a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/impl/SurplusItemReturnServiceImpl.java b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/impl/SurplusItemReturnServiceImpl.java index c0b055e8..039faf78 100644 --- a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/impl/SurplusItemReturnServiceImpl.java +++ b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/impl/SurplusItemReturnServiceImpl.java @@ -1,20 +1,34 @@ package com.foreverwin.mesnac.dispatch.service.impl; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.foreverwin.mesnac.common.enums.HandleEnum; +import com.foreverwin.mesnac.common.util.ExcelUtils; +import com.foreverwin.mesnac.common.util.ExceptionUtil; import com.foreverwin.mesnac.common.util.NumberUtil; import com.foreverwin.mesnac.common.util.StringUtil; -import com.foreverwin.mesnac.dispatch.mapper.SurplusItemReturnMapper; -import com.foreverwin.mesnac.dispatch.model.SurplusItemReturn; -import com.foreverwin.mesnac.dispatch.service.SurplusItemReturnService; import com.foreverwin.mesnac.meapi.model.Inventory; import com.foreverwin.mesnac.meapi.service.InventoryService; import com.foreverwin.modular.core.exception.BusinessException; -import org.springframework.beans.factory.annotation.Autowired; +import com.foreverwin.modular.core.meext.MEServices; +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.dispatch.model.SurplusItemReturn; +import com.foreverwin.mesnac.dispatch.mapper.SurplusItemReturnMapper; +import com.foreverwin.mesnac.dispatch.service.SurplusItemReturnService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sap.me.inventory.InventoryServiceInterface; +import com.sap.me.inventory.InventorySplitRequest; +import com.sap.me.inventory.NewSplitInventory; import org.springframework.stereotype.Service; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; import java.util.Map; +import java.util.UUID; /** *

@@ -42,7 +56,7 @@ public class SurplusItemReturnServiceImpl extends ServiceImpl splitList = new ArrayList<>(); + NewSplitInventory newSplitInventory = new NewSplitInventory(); + newSplitInventory.setNewInventoryId(surplusInventory); + newSplitInventory.setQuantity(qty); + splitList.add(newSplitInventory); + request.setNewInventoryList(splitList); + meInventoryService.split(request); + } catch (Exception e) { + ExceptionUtil.throwException(e); + } + + LocalDateTime dateTime = LocalDateTime.now(); + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + //记录余料退回日志 + SurplusItemReturn surplusItemReturn = new SurplusItemReturn(); + surplusItemReturn.setHandle(UUID.randomUUID().toString()); + surplusItemReturn.setSite(site); + surplusItemReturn.setParentInventory(inventory); + surplusItemReturn.setInventory(surplusInventory); + surplusItemReturn.setLenght(length); + surplusItemReturn.setWidth(width); + surplusItemReturn.setItemBo(inventoryModel.getItemBo()); + surplusItemReturn.setQty(qty); + surplusItemReturn.setCreateUser(user); + surplusItemReturn.setCreatedDateTime(dateTime); + surplusItemReturn.setModifuUser(user); + surplusItemReturn.setModifiedDateTime(dateTime); + surplusItemReturnMapper.insert(surplusItemReturn); + } } \ No newline at end of file diff --git a/dispatch/src/main/resources/mapper/SurplusItemReturnMapper.xml b/dispatch/src/main/resources/mapper/SurplusItemReturnMapper.xml index 026340b8..63b64e5b 100644 --- a/dispatch/src/main/resources/mapper/SurplusItemReturnMapper.xml +++ b/dispatch/src/main/resources/mapper/SurplusItemReturnMapper.xml @@ -12,15 +12,15 @@ - + - - + + - HANDLE, SITE, INVENTORY, PARENT_INVENTORY, ITEM_BO, LENGHT, WIDTH, QTY, CREATE_USER_BO, CREATED_DATE_TIME, UPDATE_USER_BO, UPDATED_DATE_TIME + HANDLE, SITE, INVENTORY, PARENT_INVENTORY, ITEM_BO, LENGHT, WIDTH, QTY, CREATE_USER, CREATED_DATE_TIME, MODIFU_USER, MODIFIED_DATE_TIME @@ -53,7 +53,7 @@ SELECT FROM Z_SURPLUS_ITEM_RETURN - HANDLE=#{ew.handle} + HANDLE=#{ew.handle} AND SITE=#{ew.entity.site} AND INVENTORY=#{ew.entity.inventory} @@ -62,10 +62,10 @@ AND LENGHT=#{ew.entity.lenght} AND WIDTH=#{ew.entity.width} AND QTY=#{ew.entity.qty} - AND CREATE_USER_BO=#{ew.entity.createUserBo} + AND CREATE_USER=#{ew.entity.createUser} AND CREATED_DATE_TIME=#{ew.entity.createdDateTime} - AND UPDATE_USER_BO=#{ew.entity.updateUserBo} - AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime} + AND MODIFU_USER=#{ew.entity.modifuUser} + AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime} @@ -74,20 +74,20 @@ - - HANDLE=#{ew.entity.handle} - - AND SITE=#{ew.entity.site} - AND INVENTORY=#{ew.entity.inventory} - AND PARENT_INVENTORY=#{ew.entity.parentInventory} - AND ITEM_BO=#{ew.entity.itemBo} - AND LENGHT=#{ew.entity.lenght} - AND WIDTH=#{ew.entity.width} - AND QTY=#{ew.entity.qty} - AND CREATE_USER_BO=#{ew.entity.createUserBo} - AND CREATED_DATE_TIME=#{ew.entity.createdDateTime} - AND UPDATE_USER_BO=#{ew.entity.updateUserBo} - AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime} + + HANDLE=#{ew.entity.handle} + + AND SITE=#{ew.entity.site} + AND INVENTORY=#{ew.entity.inventory} + AND PARENT_INVENTORY=#{ew.entity.parentInventory} + AND ITEM_BO=#{ew.entity.itemBo} + AND LENGHT=#{ew.entity.lenght} + AND WIDTH=#{ew.entity.width} + AND QTY=#{ew.entity.qty} + AND CREATE_USER=#{ew.entity.createUser} + AND CREATED_DATE_TIME=#{ew.entity.createdDateTime} + AND MODIFU_USER=#{ew.entity.modifuUser} + AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime} ${ew.sqlSegment} @@ -114,10 +114,10 @@ AND LENGHT=#{ew.entity.lenght} AND WIDTH=#{ew.entity.width} AND QTY=#{ew.entity.qty} - AND CREATE_USER_BO=#{ew.entity.createUserBo} + AND CREATE_USER=#{ew.entity.createUser} AND CREATED_DATE_TIME=#{ew.entity.createdDateTime} - AND UPDATE_USER_BO=#{ew.entity.updateUserBo} - AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime} + AND MODIFU_USER=#{ew.entity.modifuUser} + AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime} ${ew.sqlSegment} @@ -144,10 +144,10 @@ AND LENGHT=#{ew.entity.lenght} AND WIDTH=#{ew.entity.width} AND QTY=#{ew.entity.qty} - AND CREATE_USER_BO=#{ew.entity.createUserBo} + AND CREATE_USER=#{ew.entity.createUser} AND CREATED_DATE_TIME=#{ew.entity.createdDateTime} - AND UPDATE_USER_BO=#{ew.entity.updateUserBo} - AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime} + AND MODIFU_USER=#{ew.entity.modifuUser} + AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime} ${ew.sqlSegment} @@ -174,10 +174,10 @@ AND LENGHT=#{ew.entity.lenght} AND WIDTH=#{ew.entity.width} AND QTY=#{ew.entity.qty} - AND CREATE_USER_BO=#{ew.entity.createUserBo} + AND CREATE_USER=#{ew.entity.createUser} AND CREATED_DATE_TIME=#{ew.entity.createdDateTime} - AND UPDATE_USER_BO=#{ew.entity.updateUserBo} - AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime} + AND MODIFU_USER=#{ew.entity.modifuUser} + AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime} ${ew.sqlSegment} @@ -204,10 +204,10 @@ AND LENGHT=#{ew.entity.lenght} AND WIDTH=#{ew.entity.width} AND QTY=#{ew.entity.qty} - AND CREATE_USER_BO=#{ew.entity.createUserBo} + AND CREATE_USER=#{ew.entity.createUser} AND CREATED_DATE_TIME=#{ew.entity.createdDateTime} - AND UPDATE_USER_BO=#{ew.entity.updateUserBo} - AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime} + AND MODIFU_USER=#{ew.entity.modifuUser} + AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime} ${ew.sqlSegment} @@ -234,10 +234,10 @@ AND LENGHT=#{ew.entity.lenght} AND WIDTH=#{ew.entity.width} AND QTY=#{ew.entity.qty} - AND CREATE_USER_BO=#{ew.entity.createUserBo} + AND CREATE_USER=#{ew.entity.createUser} AND CREATED_DATE_TIME=#{ew.entity.createdDateTime} - AND UPDATE_USER_BO=#{ew.entity.updateUserBo} - AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime} + AND MODIFU_USER=#{ew.entity.modifuUser} + AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime} ${ew.sqlSegment} @@ -260,10 +260,10 @@ LENGHT, WIDTH, QTY, - CREATE_USER_BO, + CREATE_USER, CREATED_DATE_TIME, - UPDATE_USER_BO, - UPDATED_DATE_TIME, + MODIFU_USER, + MODIFIED_DATE_TIME, VALUES #{handle}, @@ -274,10 +274,10 @@ #{lenght}, #{width}, #{qty}, - #{createUserBo}, + #{createUser}, #{createdDateTime}, - #{updateUserBo}, - #{updatedDateTime}, + #{modifuUser}, + #{modifiedDateTime}, @@ -295,10 +295,10 @@ #{lenght}, #{width}, #{qty}, - #{createUserBo}, + #{createUser}, #{createdDateTime}, - #{updateUserBo}, - #{updatedDateTime}, + #{modifuUser}, + #{modifiedDateTime}, @@ -312,11 +312,11 @@ LENGHT=#{et.lenght}, WIDTH=#{et.width}, QTY=#{et.qty}, - CREATE_USER_BO=#{et.createUserBo}, + CREATE_USER=#{et.createUser}, CREATED_DATE_TIME=#{et.createdDateTime}, - UPDATE_USER_BO=#{et.updateUserBo}, - UPDATED_DATE_TIME=#{et.updatedDateTime}, - WHERE HANDLE=#{et.handle} and ${et.MP_OPTLOCK_VERSION_COLUMN}=#{et.MP_OPTLOCK_VERSION_ORIGINAL} + MODIFU_USER=#{et.modifuUser}, + MODIFIED_DATE_TIME=#{et.modifiedDateTime}, + WHERE HANDLE=#{et.handle} and ${et.MP_OPTLOCK_VERSION_COLUMN}=#{et.MP_OPTLOCK_VERSION_ORIGINAL} @@ -329,11 +329,11 @@ LENGHT=#{et.lenght}, WIDTH=#{et.width}, QTY=#{et.qty}, - CREATE_USER_BO=#{et.createUserBo}, + CREATE_USER=#{et.createUser}, CREATED_DATE_TIME=#{et.createdDateTime}, - UPDATE_USER_BO=#{et.updateUserBo}, - UPDATED_DATE_TIME=#{et.updatedDateTime}, - WHERE HANDLE=#{et.handle} and ${et.MP_OPTLOCK_VERSION_COLUMN}=#{et.MP_OPTLOCK_VERSION_ORIGINAL} + MODIFU_USER=#{et.modifuUser}, + MODIFIED_DATE_TIME=#{et.modifiedDateTime}, + WHERE HANDLE=#{et.handle} and ${et.MP_OPTLOCK_VERSION_COLUMN}=#{et.MP_OPTLOCK_VERSION_ORIGINAL} @@ -346,10 +346,10 @@ LENGHT=#{et.lenght}, WIDTH=#{et.width}, QTY=#{et.qty}, - CREATE_USER_BO=#{et.createUserBo}, + CREATE_USER=#{et.createUser}, CREATED_DATE_TIME=#{et.createdDateTime}, - UPDATE_USER_BO=#{et.updateUserBo}, - UPDATED_DATE_TIME=#{et.updatedDateTime}, + MODIFU_USER=#{et.modifuUser}, + MODIFIED_DATE_TIME=#{et.modifiedDateTime}, @@ -362,10 +362,10 @@ AND LENGHT=#{ew.entity.lenght} AND WIDTH=#{ew.entity.width} AND QTY=#{ew.entity.qty} - AND CREATE_USER_BO=#{ew.entity.createUserBo} + AND CREATE_USER=#{ew.entity.createUser} AND CREATED_DATE_TIME=#{ew.entity.createdDateTime} - AND UPDATE_USER_BO=#{ew.entity.updateUserBo} - AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime} + AND MODIFU_USER=#{ew.entity.modifuUser} + AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime} ${ew.sqlSegment} @@ -409,10 +409,10 @@ AND LENGHT=#{ew.entity.lenght} AND WIDTH=#{ew.entity.width} AND QTY=#{ew.entity.qty} - AND CREATE_USER_BO=#{ew.entity.createUserBo} + AND CREATE_USER=#{ew.entity.createUser} AND CREATED_DATE_TIME=#{ew.entity.createdDateTime} - AND UPDATE_USER_BO=#{ew.entity.updateUserBo} - AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime} + AND MODIFU_USER=#{ew.entity.modifuUser} + AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime} ${ew.sqlSegment} diff --git a/equip/src/main/java/com/foreverwin/mesnac/equip/consumer/ResourceMQConsume.java b/equip/src/main/java/com/foreverwin/mesnac/equip/consumer/ResourceMQConsume.java new file mode 100644 index 00000000..78ae622e --- /dev/null +++ b/equip/src/main/java/com/foreverwin/mesnac/equip/consumer/ResourceMQConsume.java @@ -0,0 +1,60 @@ +package com.foreverwin.mesnac.equip.consumer; + +import com.alibaba.fastjson.JSONObject; +import com.foreverwin.mesnac.equip.dto.MQResponseDto; +import com.foreverwin.mesnac.meapi.service.ResrceService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.jms.annotation.JmsListener; +import org.springframework.jms.core.JmsMessagingTemplate; +import org.springframework.messaging.MessageHeaders; +import org.springframework.stereotype.Component; + +import javax.jms.Queue; + + +/** + * 设备交互MQ监听类 + * + * + * @author Leon + * @date 2021-07-21 + */ +@Component +@ConditionalOnProperty(prefix = "spring.activemq", value = {"enabled"}, matchIfMissing = true) +public class ResourceMQConsume { + + private static Logger logger = LoggerFactory.getLogger(ResourceMQConsume.class); + + @Autowired + private ResourceMQProcess resourceMQProcess; + + @Autowired + @Qualifier("defaultJmsTemplate") + private JmsMessagingTemplate template; + + @JmsListener(destination = "resource.status.process", containerFactory = "defaultFactory") + public void resourceStatusProcess(String text, MessageHeaders headers) { + logger.info("接收设备状态变更数据:" + text); + + String resultString = resourceMQProcess.resourceStatusProcess(text); + //返回设备处理结果 + template.convertAndSend((Queue) headers.get("jms_replyTo"), resultString); + } + + @JmsListener(destination = "resource.alarm.process", containerFactory = "defaultFactory") + public void resourceAlarmProcess(String text, MessageHeaders headers) { + logger.info("接收设备报警数据:" + text); + + template.convertAndSend((Queue) headers.get("jms_replyTo"), ""); + } + + @JmsListener(destination = "resource.edc.process", containerFactory = "defaultFactory") + public void resourceEdcProcess(String text) { + logger.info("接收设备参数数据:" + text); + + } +} diff --git a/equip/src/main/java/com/foreverwin/mesnac/equip/consumer/ResourceMQProcess.java b/equip/src/main/java/com/foreverwin/mesnac/equip/consumer/ResourceMQProcess.java new file mode 100644 index 00000000..16e59113 --- /dev/null +++ b/equip/src/main/java/com/foreverwin/mesnac/equip/consumer/ResourceMQProcess.java @@ -0,0 +1,79 @@ +package com.foreverwin.mesnac.equip.consumer; + +import com.alibaba.fastjson.JSONObject; +import com.foreverwin.mesnac.common.util.StringUtil; +import com.foreverwin.mesnac.equip.dto.MQResponseDto; +import com.foreverwin.mesnac.meapi.service.ResrceService; +import com.foreverwin.modular.core.exception.BusinessException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 设备接口业务处理 + * + * + * @author Leon + * @date 2021-07-21 + */ +@Component +public class ResourceMQProcess { + + + @Autowired + private ResrceService resrceService; + + /** + * 设备状态变更 + * + * + * 设备状态:运行/RUN(301|已启用);停机/DOW(302|已禁用);维修/REPAIR(4/预定停机);封存/SEAL(303|保留);空闲/FREE(2|备用) + * @param text + * @return + */ + public String resourceStatusProcess(String text) { + MQResponseDto mqResponseDto = new MQResponseDto(); + + try { + JSONObject jsonObject = JSONObject.parseObject(text); + String handle = jsonObject.getString("TRANID"); + mqResponseDto.setHANDLE(handle); + + String site = jsonObject.getString("SITE"); + String resource = jsonObject.getString("RESOURCE"); + String status = jsonObject.getString("STATUS"); + if (StringUtil.isBlank(site)) { + throw BusinessException.build("站点不能为空!"); + } + if (StringUtil.isBlank(resource)) { + throw BusinessException.build("设备编号不能为空!"); + } + if (StringUtil.isBlank(status)) { + throw BusinessException.build("设备状态不能为空!"); + } + + String meStatus = "301"; + //设备状态转换 + switch (status) { + case "RUN" : + meStatus = "301"; break; + case "DOW" : + meStatus = "302"; break; + case "SEAL" : + meStatus = "303"; break; + case "FREE" : + meStatus = "2"; break; + case "REPAIR" : + meStatus = "4"; break; + } + + resrceService.updateResourceStatus(site, resource, meStatus); + mqResponseDto.setSTATUS("S"); + mqResponseDto.setMESSAGE("设备状态修改成功!"); + } catch (Exception e) { + mqResponseDto.setSTATUS("E"); + mqResponseDto.setMESSAGE("设备状态修改失败:" + e.getMessage()); + } + + return JSONObject.toJSONString(mqResponseDto); + } +} diff --git a/equip/src/main/java/com/foreverwin/mesnac/equip/dto/MQResponseDto.java b/equip/src/main/java/com/foreverwin/mesnac/equip/dto/MQResponseDto.java new file mode 100644 index 00000000..37b1bdbb --- /dev/null +++ b/equip/src/main/java/com/foreverwin/mesnac/equip/dto/MQResponseDto.java @@ -0,0 +1,44 @@ +package com.foreverwin.mesnac.equip.dto; + +import com.alibaba.fastjson.annotation.JSONField; + +/** + * 设备交互MQ返回值类 + * + * + * @author Leon + * @date 2021-07-21 + */ +public class MQResponseDto { + + @JSONField + private String HANDLE; + @JSONField + private String STATUS; + @JSONField + private String MESSAGE; + + public String getHANDLE() { + return HANDLE; + } + + public void setHANDLE(String HANDLE) { + this.HANDLE = HANDLE; + } + + public String getSTATUS() { + return STATUS; + } + + public void setSTATUS(String STATUS) { + this.STATUS = STATUS; + } + + public String getMESSAGE() { + return MESSAGE; + } + + public void setMESSAGE(String MESSAGE) { + this.MESSAGE = MESSAGE; + } +} diff --git a/equip/src/main/java/com/foreverwin/mesnac/equip/service/impl/ResourceRepairTaskServiceImpl.java b/equip/src/main/java/com/foreverwin/mesnac/equip/service/impl/ResourceRepairTaskServiceImpl.java index a925e9f6..db82dade 100644 --- a/equip/src/main/java/com/foreverwin/mesnac/equip/service/impl/ResourceRepairTaskServiceImpl.java +++ b/equip/src/main/java/com/foreverwin/mesnac/equip/service/impl/ResourceRepairTaskServiceImpl.java @@ -135,8 +135,7 @@ public class ResourceRepairTaskServiceImpl extends ServiceImpl { /** * 仅修改设备状态 */ - void updateResourceStatusByHandle(String handle,String status); + void updateResourceStatus(String site, String resource, String status); /** * 根据设备类型、站点,获取该类型的所有设备 diff --git a/meapi/src/main/java/com/foreverwin/mesnac/meapi/service/impl/ResrceServiceImpl.java b/meapi/src/main/java/com/foreverwin/mesnac/meapi/service/impl/ResrceServiceImpl.java index 6a337939..75f748bd 100644 --- a/meapi/src/main/java/com/foreverwin/mesnac/meapi/service/impl/ResrceServiceImpl.java +++ b/meapi/src/main/java/com/foreverwin/mesnac/meapi/service/impl/ResrceServiceImpl.java @@ -69,9 +69,13 @@ public class ResrceServiceImpl extends ServiceImpl impleme } @Override - public void updateResourceStatusByHandle(String handle,String status) { - Resrce resrce = resrceMapper.selectById(handle); - resrce.setStatusBo("StatusBo:1000,"+status); + public void updateResourceStatus(String site, String resource, String status) { + String statusBo = "StatusBo:" + site + "," + status; + String resourceBo = "ResourceBO:" + site + "," + resource; + + Resrce resrce = new Resrce(); + resrce.setHandle(resourceBo); + resrce.setStatusBo(statusBo); resrceMapper.updateById(resrce); } diff --git a/production/src/main/java/com/foreverwin/mesnac/production/service/impl/PodTemplateServiceImpl.java b/production/src/main/java/com/foreverwin/mesnac/production/service/impl/PodTemplateServiceImpl.java index 35da3455..92abfd5d 100644 --- a/production/src/main/java/com/foreverwin/mesnac/production/service/impl/PodTemplateServiceImpl.java +++ b/production/src/main/java/com/foreverwin/mesnac/production/service/impl/PodTemplateServiceImpl.java @@ -210,6 +210,7 @@ public class PodTemplateServiceImpl implements PodTemplateService { if (StringUtil.isBlank(resrce)){ throw new BaseException("资源不能为空"); } + sfcDtoList.forEach(sfcDto -> { String site = CommonMethods.getSite(); String operation = sfcDto.getOperation(); @@ -220,14 +221,6 @@ public class PodTemplateServiceImpl implements PodTemplateService { String dispatchNo = sfcDto.getDispatchNo(); Sfc sfcServiceById = sfcService.getById(HandleEnum.SFC.getHandle(site, sfc)); BigDecimal qty=new BigDecimal(sfcServiceById.getQty().toString()); - try { - sfcCrossService.completeAction(site, currentRevisionRef.getHandle(),resrce,sfcServiceById.getHandle(),qty); - } catch (Exception e) { - ExceptionUtil.throwException(e); - } - //更改派工单状态 - sfcDispatchCommonService.updateSfcDispatchStatus(site,CommonMethods.getUser(),dispatchNo, DispatchStatusEnum.COMPLETE.getCode()); - //是否有自检检验项目 List inspectionItemDetails = inspectionItemService.selectQualityInspection(sfc, operation, stepId, Constants.INSPECTION_TYPE_Z); if (inspectionItemDetails.size()>0&&inspectionItemDetails.get(0)!=null) { @@ -240,7 +233,13 @@ public class PodTemplateServiceImpl implements PodTemplateService { throw new BaseException("自检任务不合格,不能完成请检查"); } } - + try { + sfcCrossService.completeAction(site, currentRevisionRef.getHandle(),resrce,sfcServiceById.getHandle(),qty); + } catch (Exception e) { + ExceptionUtil.throwException(e); + } + //更改派工单状态 + sfcDispatchCommonService.updateSfcDispatchStatus(site,CommonMethods.getUser(),dispatchNo, DispatchStatusEnum.COMPLETE.getCode()); }); } }