Commit 5d34280e zshaohui

其他设备 功能提交

1 个父辈 4d57acc7
...@@ -233,6 +233,7 @@ public class MenuInit { ...@@ -233,6 +233,7 @@ public class MenuInit {
addDefaultFunctionMenu(105,poutSet, "资源翻译", "translation", "system/translation/index", "translation"); addDefaultFunctionMenu(105,poutSet, "资源翻译", "translation", "system/translation/index", "translation");
// Menu orderSet = new Menu(, "orderSetting", "工单设置", "orderSetting", "system/orderSetting/index", "sysSet"); // Menu orderSet = new Menu(, "orderSetting", "工单设置", "orderSetting", "system/orderSetting/index", "sysSet");
addDefaultFunctionMenu(106,poutSet, "料架设置", "shelfSetting", "system/shelfSetting/index", "translation",NL_SHOW_MENU); addDefaultFunctionMenu(106,poutSet, "料架设置", "shelfSetting", "system/shelfSetting/index", "translation",NL_SHOW_MENU);
addDefaultFunctionMenu(107,poutSet, "其他设备", "storageOther", "storage/storageOther/index", "storageOther");
Menu helpAbout = Menu.CreatePMenu("帮助", 9999, "help", "help",null); Menu helpAbout = Menu.CreatePMenu("帮助", 9999, "help", "help",null);
addDefaultFunctionMenu(99991, helpAbout, "说明书", "instruction", "system/instruction/index","aboutBook"); addDefaultFunctionMenu(99991, helpAbout, "说明书", "instruction", "system/instruction/index","aboutBook");
......
package com.neotel.smfcore.core.equipment.enums; package com.neotel.smfcore.core.equipment.enums;
import com.google.common.collect.Lists;
import com.neotel.smfcore.core.storage.enums.DeviceType;
import java.util.List;
/** /**
* 设备类型(非料仓) * 设备类型(非料仓)
*/ */
...@@ -55,5 +60,10 @@ public enum EquipmentType { ...@@ -55,5 +60,10 @@ public enum EquipmentType {
/** /**
* NEXIM * NEXIM
*/ */
NEXIM() NEXIM();
public static List<EquipmentType> availableTypeList(){
return Lists.newArrayList(AUTO,NEOSCAN,NS200,COUNTING,NEOSTATION,FUJINEOLINK,PANACIMNEOLINK,AGV,HANWHA,NEXIM);
}
} }
...@@ -47,13 +47,15 @@ public class EquipCommunicationController { ...@@ -47,13 +47,15 @@ public class EquipCommunicationController {
String name = statusBean.getName(); String name = statusBean.getName();
Equipment equipment = equipmentCache.getEquipment(cid); Equipment equipment = equipmentCache.getEquipment(cid);
if (equipment == null) { if (equipment == null) {
equipment = equipmentCache.autoCreateEquip(name,cid, statusBean.getType()); /*equipment = equipmentCache.autoCreateEquip(name,cid, statusBean.getType());
if (equipment != null) { if (equipment != null) {
log.error("设备cid: [" + cid + "]不存在,自动创建设备完成"); log.error("设备cid: [" + cid + "]不存在,自动创建设备完成");
} else { } else {
log.error("设备cid: [" + cid + "]不存在,自动创建设备失败"); log.error("设备cid: [" + cid + "]不存在,自动创建设备失败");
return null; return null;
} }*/
log.info("设备cid: [" + cid + "]不存在");
return null;
} else { } else {
if (StringUtils.isNotBlank(name)) { if (StringUtils.isNotBlank(name)) {
if (!name.equals(equipment.getName())) { if (!name.equals(equipment.getName())) {
......
package com.neotel.smfcore.core.equipment.rest; package com.neotel.smfcore.core.equipment.rest;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.QueryHelp;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.equipment.enums.EquipmentType;
import com.neotel.smfcore.core.equipment.rest.dto.EquipmentDto;
import com.neotel.smfcore.core.equipment.rest.mapstruct.EquipmentMapper;
import com.neotel.smfcore.core.equipment.rest.query.EquipmentQueryCriteria;
import com.neotel.smfcore.core.equipment.service.manager.IEquipmentManager;
import com.neotel.smfcore.core.equipment.service.po.Equipment;
import com.neotel.smfcore.core.equipment.util.EquipmentCache;
import com.neotel.smfcore.core.storage.rest.dto.StorageDto;
import com.neotel.smfcore.core.storage.rest.query.StorageQueryCriteria;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController; import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@Slf4j @Slf4j
@RestController @RestController
...@@ -12,4 +39,117 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -12,4 +39,117 @@ import org.springframework.web.bind.annotation.RestController;
@Api(tags = "设备管理(非料仓)") @Api(tags = "设备管理(非料仓)")
@RequestMapping("api/equipment") @RequestMapping("api/equipment")
public class EquipmentController { public class EquipmentController {
@Autowired
private IEquipmentManager equipmentManager;
@Autowired
private EquipmentMapper equipmentMapper;
@Autowired
private EquipmentCache equipmentCache;
@ApiOperation("查询非料仓设备")
@GetMapping
//@AnonymousAccess
public PageData<EquipmentDto> query(EquipmentQueryCriteria criteria, Pageable pageable){
Query query= QueryHelp.getQuery(criteria);
PageData<Equipment> pages = equipmentManager.findByPage(query, pageable);
List<EquipmentDto> equipmentDtos =equipmentMapper.toDto(pages.getContent());
return new PageData(equipmentDtos,pages.getTotalElements());
}
@ApiOperation("新增非料仓")
@PostMapping
//@AnonymousAccess
public ResponseEntity<Object> create(@Validated @RequestBody EquipmentDto equipmentDto) {
Equipment equipment = equipmentMapper.toEntity(equipmentDto);
if(StringUtils.isEmpty(equipment.getName())){
throw new ValidateException("smfcore.valueCanotNull","{0}不能为空",new String[]{"name"} );
} if(StringUtils.isEmpty(equipment.getCid())){
throw new ValidateException("smfcore.valueCanotNull","{0}不能为空",new String[]{"cid"} );
} if(StringUtils.isEmpty(equipment.getType())){
throw new ValidateException("smfcore.valueCanotNull","{0}不能为空",new String[]{"type"} );
}
for (Equipment equ : equipmentCache.getAllEquipment().values()) {
if (!equipment.getId().equals(equ.getId())){
if(equipment.getName().equals(equ.getName())){
throw new ValidateException("smfcore.valueAlreadyExist","{0}[{1}]已存在",new String[]{"name",equipment.getName()});
}
if(equipment.getCid().equals(equ.getCid())){
throw new ValidateException("smfcore.valueAlreadyExist","{0}[{1}]已存在",new String[]{"cid",equipment.getCid()});
}
}
}
equipment = equipmentManager.save(equipment);
equipmentCache.reloadEquipment(equipment,equipment.getCid());
return new ResponseEntity<>(HttpStatus.CREATED);
}
@ApiOperation("修改非料仓")
@PutMapping
//@AnonymousAccess
public ResponseEntity<Object> update(@Validated @RequestBody EquipmentDto equipmentDto) {
Equipment equipment=equipmentMapper.toEntity(equipmentDto);
if (StringUtils.isEmpty(equipment.getId())) {
throw new ValidateException("smfcore.valueCanotNull","{0}不能为空",new String[]{"ID"} );
}
if(StringUtils.isEmpty(equipment.getName())){
throw new ValidateException("smfcore.valueCanotNull","{0}不能为空",new String[]{"name"} );
} if(StringUtils.isEmpty(equipment.getCid())){
throw new ValidateException("smfcore.valueCanotNull","{0}不能为空",new String[]{"cid"} );
} if(StringUtils.isEmpty(equipment.getType())){
throw new ValidateException("smfcore.valueCanotNull","{0}不能为空",new String[]{"type"} );
}
for (Equipment equ : equipmentCache.getAllEquipment().values()) {
if (!equipment.getId().equals(equ.getId())){
if(equipment.getName().equals(equ.getName())){
throw new ValidateException("smfcore.valueAlreadyExist","{0}[{1}]已存在",new String[]{"name",equipment.getName()});
}
if(equipment.getCid().equals(equ.getCid())){
throw new ValidateException("smfcore.valueAlreadyExist","{0}[{1}]已存在",new String[]{"cid",equipment.getCid()});
}
}
}
equipmentManager.save(equipment);
equipmentCache.reloadEquipment(equipment,equipment.getCid());
return new ResponseEntity<>(HttpStatus.OK);
}
@ApiOperation("删除非料仓设备")
@DeleteMapping
//@AnonymousAccess
public ResponseEntity<Object> delete(@RequestBody Set<String> ids) {
for (String id : ids) {
if (id == null) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"ID"});
}
}
for (String id : ids) {
Equipment equipment = equipmentManager.get(id);
if (equipment == null){
continue;
}
equipmentManager.deleteById(id);
log.info(SecurityUtils.getLoginUsername()+"手动删除设备[{}]",equipment.getName());
}
return new ResponseEntity<>(HttpStatus.OK);
}
@ApiOperation("返回所有非料仓类型")
@GetMapping(value = "/typeList")
//@AnonymousAccess
public List<String> typeList() {
List<EquipmentType> availableTypeList= EquipmentType.availableTypeList();
List<String> allList=new ArrayList<>();
for (EquipmentType type :
availableTypeList) {
allList.add(type.name());
}
return allList;
}
} }
...@@ -20,4 +20,6 @@ public class EquipmentDto { ...@@ -20,4 +20,6 @@ public class EquipmentDto {
@ApiModelProperty("是否可用") @ApiModelProperty("是否可用")
private boolean available = true; private boolean available = true;
private String id;
} }
package com.neotel.smfcore.core.equipment.rest.mapstruct;
import com.neotel.smfcore.common.base.BaseMapper;
import com.neotel.smfcore.core.equipment.rest.dto.EquipmentDto;
import com.neotel.smfcore.core.equipment.service.po.Equipment;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
@Mapper(componentModel = "spring" ,unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface EquipmentMapper extends BaseMapper<EquipmentDto, Equipment> {
}
package com.neotel.smfcore.core.equipment.rest.query;
import com.neotel.smfcore.common.annotation.QueryCondition;
import com.neotel.smfcore.common.bean.BetweenData;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
public class EquipmentQueryCriteria {
@QueryCondition(blurry = "name,cid")
private String blurry;
@QueryCondition(type = QueryCondition.Type.BETWEEN, propName = "updateDate")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private BetweenData<Date> createDate;
}
package com.neotel.smfcore.core.equipment.service.manager; package com.neotel.smfcore.core.equipment.service.manager;
import com.neotel.smfcore.common.base.IBaseManager; import com.neotel.smfcore.common.base.IBaseManager;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.core.equipment.service.po.Equipment; import com.neotel.smfcore.core.equipment.service.po.Equipment;
import java.util.List; import java.util.List;
public interface IEquipmentManager extends IBaseManager<Equipment> { public interface IEquipmentManager extends IBaseManager<Equipment> {
List<Equipment> findAll(); List<Equipment> findAll();
void deleteById(String id);
} }
...@@ -50,4 +50,9 @@ public class EquipmentManagerImpl implements IEquipmentManager { ...@@ -50,4 +50,9 @@ public class EquipmentManagerImpl implements IEquipmentManager {
public List<Equipment> findAll(){ public List<Equipment> findAll(){
return equipmentDao.findAll(); return equipmentDao.findAll();
} }
@Override
public void deleteById(String id) {
equipmentDao.removeOneById(id);
}
} }
...@@ -401,4 +401,5 @@ smfcore.storagePos.available=\u662F\u5426\u53EF\u7528 ...@@ -401,4 +401,5 @@ smfcore.storagePos.available=\u662F\u5426\u53EF\u7528
smfcore.storagePos.yes=\u662F smfcore.storagePos.yes=\u662F
smfcore.storagePos.no=\u5426 smfcore.storagePos.no=\u5426
smfcore.dashBoard=\u4EEA\u8868\u76D8 smfcore.dashBoard=\u4EEA\u8868\u76D8
smfcore.spHumiture=\u6E29\u6E7F\u5EA6
\ No newline at end of file \ No newline at end of file
smfcore.spHumiture=\u6E29\u6E7F\u5EA6
smfcore.storageOther=\u5176\u4ED6\u8BBE\u5907
\ No newline at end of file \ No newline at end of file
...@@ -392,4 +392,5 @@ smfcore.storagePos.available=Available ...@@ -392,4 +392,5 @@ smfcore.storagePos.available=Available
smfcore.storagePos.yes=Yes smfcore.storagePos.yes=Yes
smfcore.storagePos.no=No smfcore.storagePos.no=No
smfcore.dashBoard=Dashboard smfcore.dashBoard=Dashboard
smfcore.spHumiture=Temperature & Humidity
\ No newline at end of file \ No newline at end of file
smfcore.spHumiture=Temperature & Humidity
smfcore.storageOther = Other Devices
\ No newline at end of file \ No newline at end of file
...@@ -388,4 +388,5 @@ smfcore.storagePos.available=\u5229\u7528\u53EF\u5426 ...@@ -388,4 +388,5 @@ smfcore.storagePos.available=\u5229\u7528\u53EF\u5426
smfcore.storagePos.yes=\u662F smfcore.storagePos.yes=\u662F
smfcore.storagePos.no=\u5426 smfcore.storagePos.no=\u5426
smfcore.dashBoard=\u30C0\u30C3\u30B7\u30E5\u30DC\u30FC\u30C9 smfcore.dashBoard=\u30C0\u30C3\u30B7\u30E5\u30DC\u30FC\u30C9
smfcore.spHumiture=\u6E29\u6E7F\u5EA6
\ No newline at end of file \ No newline at end of file
smfcore.spHumiture=\u6E29\u6E7F\u5EA6
smfcore.storageOther = \u305D\u306E\u4ED6\u6A5F\u5668
\ No newline at end of file \ No newline at end of file
...@@ -388,4 +388,5 @@ smfcore.storagePos.available=\u662F\u5426\u53EF\u7528 ...@@ -388,4 +388,5 @@ smfcore.storagePos.available=\u662F\u5426\u53EF\u7528
smfcore.storagePos.yes=\u662F smfcore.storagePos.yes=\u662F
smfcore.storagePos.no=\u5426 smfcore.storagePos.no=\u5426
smfcore.dashBoard=\u4EEA\u8868\u76D8 smfcore.dashBoard=\u4EEA\u8868\u76D8
smfcore.spHumiture=\u6E29\u6E7F\u5EA6
\ No newline at end of file \ No newline at end of file
smfcore.spHumiture=\u6E29\u6E7F\u5EA6
smfcore.storageOther=\u5176\u4ED6\u8BBE\u5907
\ No newline at end of file \ No newline at end of file
...@@ -388,4 +388,5 @@ smfcore.storagePos.available=\u662F\u5426\u53EF\u7528 ...@@ -388,4 +388,5 @@ smfcore.storagePos.available=\u662F\u5426\u53EF\u7528
smfcore.storagePos.yes=\u662F smfcore.storagePos.yes=\u662F
smfcore.storagePos.no=\u5426 smfcore.storagePos.no=\u5426
smfcore.dashBoard=SP\u5100\u9336\u76E4 smfcore.dashBoard=SP\u5100\u9336\u76E4
smfcore.spHumiture=\u6E29\u6E7F\u5EA6
\ No newline at end of file \ No newline at end of file
smfcore.spHumiture=\u6E29\u6E7F\u5EA6
smfcore.storageOther=\u5176\u4ED6\u8A2D\u5099
\ No newline at end of file \ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!