zpl 4 years ago
commit 9d0dcb07db

@ -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;
}
}

@ -33,7 +33,7 @@ public class InspectionTaskController {
@PostMapping("/save")
public R getInspectionTaskList(@RequestBody Map<String, Object> paramMap){
inspectionTaskService.saveTask(paramMap);
return R.ok("保存成功");
return R.ok(null,"保存成功");
}
@ResponseBody
@RequestMapping(method = RequestMethod.POST, value = "/createTask")

@ -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

@ -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+ "】余料退回操作成功!");
}
}

@ -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<SurplusItemReturn> {
private static final long serialVersionUID = 1L;
@ -54,22 +55,22 @@ public class SurplusItemReturn extends Model<SurplusItemReturn> {
*
*/
@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<SurplusItemReturn> {
/**
*
*/
@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<SurplusItemReturn> {
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<SurplusItemReturn> {
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 +
"}";
}
}

@ -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<SurplusItemReturn> {
* @return
*/
Map<String, Object> 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);
}

@ -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;
/**
* <p>
@ -42,7 +56,7 @@ public class SurplusItemReturnServiceImpl extends ServiceImpl<SurplusItemReturnM
if (inventoryModel == null) {
throw BusinessException.build("物料条码【" + inventory +"】不存在!");
}
if (inventoryModel.getQtyOnHand().doubleValue() <= 0) {
if (inventoryModel.getQtyOnHand().compareTo(BigDecimal.ZERO) <= 0) {
throw BusinessException.build("物料条码【" + inventory +"】没有可用数量!");
}
@ -66,4 +80,75 @@ public class SurplusItemReturnServiceImpl extends ServiceImpl<SurplusItemReturnM
return map;
}
@Override
public void surplusReturn(String site, String user, String inventory, String length, String width, BigDecimal qty) {
String inventoryBo = HandleEnum.INVENTORY.getHandle(site, inventory);
Inventory inventoryModel = inventoryService.getById(inventoryBo);
if (inventoryModel == null) {
throw BusinessException.build("物料条码【" + inventory +"】不存在!");
}
BigDecimal qtyOnHand = inventoryModel.getQtyOnHand();
if (qtyOnHand.compareTo(BigDecimal.ZERO) <= 0) {
throw BusinessException.build("物料条码【" + inventory +"】没有可用数量!");
}
if (qtyOnHand.compareTo(qty) < 0) {
throw BusinessException.build("余料数量超过了物料条码现有数量【" +qtyOnHand+ "】!");
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InventoryServiceInterface meInventoryService;
try {
meInventoryService = MEServices.create("com.sap.me.inventory", "InventoryService", site);
} catch (Exception e) {
throw BusinessException.build("获取标准库存操作服务失败:" + e.getMessage());
}
//余料库存
StringBuffer _inventory = new StringBuffer(inventory);
if (StringUtil.notBlank(length)) {
_inventory.append("*"+length);
}
if (StringUtil.notBlank(width)) {
_inventory.append("*"+width);
}
String surplusInventory = _inventory.toString();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//库存拆分
try {
InventorySplitRequest request = new InventorySplitRequest();
request.setInventoryRef(inventoryBo);
request.setQuantityToSplit(qty);
List<NewSplitInventory> 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);
}
}

@ -12,15 +12,15 @@
<result column="LENGHT" property="lenght" />
<result column="WIDTH" property="width" />
<result column="QTY" property="qty" />
<result column="CREATE_USER_BO" property="createUserBo" />
<result column="CREATE_USER" property="createUser" />
<result column="CREATED_DATE_TIME" property="createdDateTime" />
<result column="UPDATE_USER_BO" property="updateUserBo" />
<result column="UPDATED_DATE_TIME" property="updatedDateTime" />
<result column="MODIFU_USER" property="modifuUser" />
<result column="MODIFIED_DATE_TIME" property="modifiedDateTime" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
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
</sql>
<!-- BaseMapper标准查询/修改/删除 -->
@ -53,7 +53,7 @@
SELECT <include refid="Base_Column_List"></include> FROM Z_SURPLUS_ITEM_RETURN
<where>
<if test="ew.entity.handle!=null">
HANDLE=#{ew.handle}
HANDLE=#{ew.handle}
</if>
<if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
<if test="ew.entity.inventory!=null"> AND INVENTORY=#{ew.entity.inventory}</if>
@ -62,10 +62,10 @@
<if test="ew.entity.lenght!=null"> AND LENGHT=#{ew.entity.lenght}</if>
<if test="ew.entity.width!=null"> AND WIDTH=#{ew.entity.width}</if>
<if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
<if test="ew.entity.createUserBo!=null"> AND CREATE_USER_BO=#{ew.entity.createUserBo}</if>
<if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.updateUserBo!=null"> AND UPDATE_USER_BO=#{ew.entity.updateUserBo}</if>
<if test="ew.entity.updatedDateTime!=null"> AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime}</if>
<if test="ew.entity.modifuUser!=null"> AND MODIFU_USER=#{ew.entity.modifuUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
</where>
</select>
@ -74,20 +74,20 @@
<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.inventory!=null"> AND INVENTORY=#{ew.entity.inventory}</if>
<if test="ew.entity.parentInventory!=null"> AND PARENT_INVENTORY=#{ew.entity.parentInventory}</if>
<if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
<if test="ew.entity.lenght!=null"> AND LENGHT=#{ew.entity.lenght}</if>
<if test="ew.entity.width!=null"> AND WIDTH=#{ew.entity.width}</if>
<if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
<if test="ew.entity.createUserBo!=null"> AND CREATE_USER_BO=#{ew.entity.createUserBo}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.updateUserBo!=null"> AND UPDATE_USER_BO=#{ew.entity.updateUserBo}</if>
<if test="ew.entity.updatedDateTime!=null"> AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime}</if>
<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.inventory!=null"> AND INVENTORY=#{ew.entity.inventory}</if>
<if test="ew.entity.parentInventory!=null"> AND PARENT_INVENTORY=#{ew.entity.parentInventory}</if>
<if test="ew.entity.itemBo!=null"> AND ITEM_BO=#{ew.entity.itemBo}</if>
<if test="ew.entity.lenght!=null"> AND LENGHT=#{ew.entity.lenght}</if>
<if test="ew.entity.width!=null"> AND WIDTH=#{ew.entity.width}</if>
<if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
<if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.modifuUser!=null"> AND MODIFU_USER=#{ew.entity.modifuUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
@ -114,10 +114,10 @@
<if test="ew.entity.lenght!=null"> AND LENGHT=#{ew.entity.lenght}</if>
<if test="ew.entity.width!=null"> AND WIDTH=#{ew.entity.width}</if>
<if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
<if test="ew.entity.createUserBo!=null"> AND CREATE_USER_BO=#{ew.entity.createUserBo}</if>
<if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.updateUserBo!=null"> AND UPDATE_USER_BO=#{ew.entity.updateUserBo}</if>
<if test="ew.entity.updatedDateTime!=null"> AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime}</if>
<if test="ew.entity.modifuUser!=null"> AND MODIFU_USER=#{ew.entity.modifuUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
@ -144,10 +144,10 @@
<if test="ew.entity.lenght!=null"> AND LENGHT=#{ew.entity.lenght}</if>
<if test="ew.entity.width!=null"> AND WIDTH=#{ew.entity.width}</if>
<if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
<if test="ew.entity.createUserBo!=null"> AND CREATE_USER_BO=#{ew.entity.createUserBo}</if>
<if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.updateUserBo!=null"> AND UPDATE_USER_BO=#{ew.entity.updateUserBo}</if>
<if test="ew.entity.updatedDateTime!=null"> AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime}</if>
<if test="ew.entity.modifuUser!=null"> AND MODIFU_USER=#{ew.entity.modifuUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
@ -174,10 +174,10 @@
<if test="ew.entity.lenght!=null"> AND LENGHT=#{ew.entity.lenght}</if>
<if test="ew.entity.width!=null"> AND WIDTH=#{ew.entity.width}</if>
<if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
<if test="ew.entity.createUserBo!=null"> AND CREATE_USER_BO=#{ew.entity.createUserBo}</if>
<if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.updateUserBo!=null"> AND UPDATE_USER_BO=#{ew.entity.updateUserBo}</if>
<if test="ew.entity.updatedDateTime!=null"> AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime}</if>
<if test="ew.entity.modifuUser!=null"> AND MODIFU_USER=#{ew.entity.modifuUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
@ -204,10 +204,10 @@
<if test="ew.entity.lenght!=null"> AND LENGHT=#{ew.entity.lenght}</if>
<if test="ew.entity.width!=null"> AND WIDTH=#{ew.entity.width}</if>
<if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
<if test="ew.entity.createUserBo!=null"> AND CREATE_USER_BO=#{ew.entity.createUserBo}</if>
<if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.updateUserBo!=null"> AND UPDATE_USER_BO=#{ew.entity.updateUserBo}</if>
<if test="ew.entity.updatedDateTime!=null"> AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime}</if>
<if test="ew.entity.modifuUser!=null"> AND MODIFU_USER=#{ew.entity.modifuUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
@ -234,10 +234,10 @@
<if test="ew.entity.lenght!=null"> AND LENGHT=#{ew.entity.lenght}</if>
<if test="ew.entity.width!=null"> AND WIDTH=#{ew.entity.width}</if>
<if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
<if test="ew.entity.createUserBo!=null"> AND CREATE_USER_BO=#{ew.entity.createUserBo}</if>
<if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.updateUserBo!=null"> AND UPDATE_USER_BO=#{ew.entity.updateUserBo}</if>
<if test="ew.entity.updatedDateTime!=null"> AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime}</if>
<if test="ew.entity.modifuUser!=null"> AND MODIFU_USER=#{ew.entity.modifuUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
@ -260,10 +260,10 @@
<if test="lenght!=null">LENGHT,</if>
<if test="width!=null">WIDTH,</if>
<if test="qty!=null">QTY,</if>
<if test="createUserBo!=null">CREATE_USER_BO,</if>
<if test="createUser!=null">CREATE_USER,</if>
<if test="createdDateTime!=null">CREATED_DATE_TIME,</if>
<if test="updateUserBo!=null">UPDATE_USER_BO,</if>
<if test="updatedDateTime!=null">UPDATED_DATE_TIME,</if>
<if test="modifuUser!=null">MODIFU_USER,</if>
<if test="modifiedDateTime!=null">MODIFIED_DATE_TIME,</if>
</trim> VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
#{handle},
@ -274,10 +274,10 @@
<if test="lenght!=null">#{lenght},</if>
<if test="width!=null">#{width},</if>
<if test="qty!=null">#{qty},</if>
<if test="createUserBo!=null">#{createUserBo},</if>
<if test="createUser!=null">#{createUser},</if>
<if test="createdDateTime!=null">#{createdDateTime},</if>
<if test="updateUserBo!=null">#{updateUserBo},</if>
<if test="updatedDateTime!=null">#{updatedDateTime},</if>
<if test="modifuUser!=null">#{modifuUser},</if>
<if test="modifiedDateTime!=null">#{modifiedDateTime},</if>
</trim>
</insert>
@ -295,10 +295,10 @@
#{lenght},
#{width},
#{qty},
#{createUserBo},
#{createUser},
#{createdDateTime},
#{updateUserBo},
#{updatedDateTime},
#{modifuUser},
#{modifiedDateTime},
</trim>
</insert>
@ -312,11 +312,11 @@
<if test="et.lenght!=null">LENGHT=#{et.lenght},</if>
<if test="et.width!=null">WIDTH=#{et.width},</if>
<if test="et.qty!=null">QTY=#{et.qty},</if>
<if test="et.createUserBo!=null">CREATE_USER_BO=#{et.createUserBo},</if>
<if test="et.createUser!=null">CREATE_USER=#{et.createUser},</if>
<if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if>
<if test="et.updateUserBo!=null">UPDATE_USER_BO=#{et.updateUserBo},</if>
<if test="et.updatedDateTime!=null">UPDATED_DATE_TIME=#{et.updatedDateTime},</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>
<if test="et.modifuUser!=null">MODIFU_USER=#{et.modifuUser},</if>
<if test="et.modifiedDateTime!=null">MODIFIED_DATE_TIME=#{et.modifiedDateTime},</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>
@ -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},
</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>
MODIFU_USER=#{et.modifuUser},
MODIFIED_DATE_TIME=#{et.modifiedDateTime},
</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>
@ -346,10 +346,10 @@
<if test="et.lenght!=null">LENGHT=#{et.lenght},</if>
<if test="et.width!=null">WIDTH=#{et.width},</if>
<if test="et.qty!=null">QTY=#{et.qty},</if>
<if test="et.createUserBo!=null">CREATE_USER_BO=#{et.createUserBo},</if>
<if test="et.createUser!=null">CREATE_USER=#{et.createUser},</if>
<if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if>
<if test="et.updateUserBo!=null">UPDATE_USER_BO=#{et.updateUserBo},</if>
<if test="et.updatedDateTime!=null">UPDATED_DATE_TIME=#{et.updatedDateTime},</if>
<if test="et.modifuUser!=null">MODIFU_USER=#{et.modifuUser},</if>
<if test="et.modifiedDateTime!=null">MODIFIED_DATE_TIME=#{et.modifiedDateTime},</if>
</trim>
<where>
<if test="ew!=null">
@ -362,10 +362,10 @@
<if test="ew.entity.lenght!=null"> AND LENGHT=#{ew.entity.lenght}</if>
<if test="ew.entity.width!=null"> AND WIDTH=#{ew.entity.width}</if>
<if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
<if test="ew.entity.createUserBo!=null"> AND CREATE_USER_BO=#{ew.entity.createUserBo}</if>
<if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.updateUserBo!=null"> AND UPDATE_USER_BO=#{ew.entity.updateUserBo}</if>
<if test="ew.entity.updatedDateTime!=null"> AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime}</if>
<if test="ew.entity.modifuUser!=null"> AND MODIFU_USER=#{ew.entity.modifuUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
@ -409,10 +409,10 @@
<if test="ew.entity.lenght!=null"> AND LENGHT=#{ew.entity.lenght}</if>
<if test="ew.entity.width!=null"> AND WIDTH=#{ew.entity.width}</if>
<if test="ew.entity.qty!=null"> AND QTY=#{ew.entity.qty}</if>
<if test="ew.entity.createUserBo!=null"> AND CREATE_USER_BO=#{ew.entity.createUserBo}</if>
<if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
<if test="ew.entity.updateUserBo!=null"> AND UPDATE_USER_BO=#{ew.entity.updateUserBo}</if>
<if test="ew.entity.updatedDateTime!=null"> AND UPDATED_DATE_TIME=#{ew.entity.updatedDateTime}</if>
<if test="ew.entity.modifuUser!=null"> AND MODIFU_USER=#{ew.entity.modifuUser}</if>
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}

@ -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);
}
}

@ -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);
}
}

@ -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;
}
}

@ -135,8 +135,7 @@ public class ResourceRepairTaskServiceImpl extends ServiceImpl<ResourceRepairTas
// 修改设备状态---若stopMachie=Y则状态改为非预定停机
if (stopMachine.equals("Y")){
String resourceNo = repairTask.getResourceNo();
String resourceBo = HandleEnum.RESOURCE.getHandle(site, resourceNo);
resrceService.updateResourceStatusByHandle(resourceBo,"5");
resrceService.updateResourceStatus(site, resourceNo ,"5");
}
}
return repairTask;
@ -177,8 +176,7 @@ public class ResourceRepairTaskServiceImpl extends ServiceImpl<ResourceRepairTas
String stopMachineT = repairTask.getStopMachine();
if (!stopMachine.equals(stopMachineT)){
String resourceNo = repairTask.getResourceNo();
String resourceBo = HandleEnum.RESOURCE.getHandle(site, resourceNo);
resrceService.updateResourceStatusByHandle(resourceBo,stopMachineT.equals("N")?"301":"5");
resrceService.updateResourceStatus(site, resourceNo, stopMachineT.equals("N")?"301":"5");
}
break;
case "302":

@ -51,7 +51,7 @@ public interface ResrceService extends IService<Resrce> {
/**
*
*/
void updateResourceStatusByHandle(String handle,String status);
void updateResourceStatus(String site, String resource, String status);
/**
*

@ -69,9 +69,13 @@ public class ResrceServiceImpl extends ServiceImpl<ResrceMapper, Resrce> 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);
}

@ -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<InspectionItemDetail> 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());
});
}
}

Loading…
Cancel
Save