yaoyq 4 жил өмнө
parent
commit
c5fdb33a1f
11 өөрчлөгдсөн 622 нэмэгдсэн , 33 устгасан
  1. 17 16
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/mq/TaskWorkNode.java
  2. 36 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/dao/ProductionresourceBizMapper.java
  3. 53 12
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/ProgramServiceImpl.java
  4. 73 0
      imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/productionResourceCenter/ProductionresourceBizMapper.xml
  5. 319 0
      imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/productionResourceCenter/entity/Productionresource.java
  6. 28 0
      imcs-admin-boot/imcs-common/src/main/java/com/github/zuihou/common/constant/UrlConfConstant.java
  7. 10 5
      imcs-admin-boot/imcs-file-biz/src/main/java/com/github/zuihou/file/service/impl/AttachmentServiceImpl.java
  8. 2 0
      imcs-admin-boot/imcs-file-biz/src/main/java/com/github/zuihou/file/strategy/FileStrategy.java
  9. 59 0
      imcs-admin-boot/imcs-file-biz/src/main/java/com/github/zuihou/file/strategy/impl/AbstractFileStrategy.java
  10. 20 0
      imcs-admin-boot/imcs-file-controller/src/main/java/com/github/zuihou/file/controller/AttachmentController.java
  11. 5 0
      imcs-admin-boot/imcs-tenant-entity/src/main/java/com/github/zuihou/tenant/entity/Productionresource.java

+ 17 - 16
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/mq/TaskWorkNode.java

@@ -25,6 +25,7 @@ import com.github.zuihou.business.util.MsgUtil;
 import com.github.zuihou.common.constant.BizConstant;
 import com.github.zuihou.common.constant.CacheKey;
 import com.github.zuihou.common.constant.DictionaryKey;
+import com.github.zuihou.common.constant.UrlConfConstant;
 import com.github.zuihou.common.util.StringUtil;
 import com.github.zuihou.context.BaseContextHandler;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
@@ -87,17 +88,17 @@ public class TaskWorkNode {
 
     private NodeOperationService nodeOperationService;
 
-    private String url = "http://127.0.0.1:8764/task/testTask";
-
-    private String plcURL = "http://192.168.170.202:8089";
-
-    private String agvURL = "http://localhost:9099/api/authority/mock/mockWms";
-    //质量中心
-    private String ZK_ip_zlzx = "192.168.170.61";
-    //柔性
-    private String ZK_ip_rxx = "192.168.170.71";
-    //智能单元
-    private String ZK_ip_zndy = "192.168.170.81";
+//    private String url = "http://127.0.0.1:8764/task/testTask";
+//
+//    private String plcURL = "http://192.168.170.202:8089";
+//
+//    private String agvURL = "http://localhost:9099/api/authority/mock/mockWms";
+//    //质量中心
+//    private String ZK_ip_zlzx = "192.168.170.61";
+//    //柔性
+//    private String ZK_ip_rxx = "192.168.170.71";
+//    //智能单元
+//    private String ZK_ip_zndy = "192.168.170.81";
 
     //总控端口
     private String ZK_port = "120";
@@ -221,21 +222,21 @@ public class TaskWorkNode {
     public String getInterfaceUrl(TaskNode taskNode) {
         String autoProgrameUrl = "";
         if (DictionaryKey.INTERFACETYPE_PLC.equals(taskNode.getInterfaceType())) {//总控
-            autoProgrameUrl = plcURL;
+            autoProgrameUrl = UrlConfConstant.plcURL;
         } else if (DictionaryKey.INTERFACETYPE_PRO.equals(taskNode.getInterfaceType())) {
 //            autoProgrameUrl = parameterService.getValue(ParameterKey.AUTOPROGRAMEURL, null);
-            autoProgrameUrl = plcURL;
+            autoProgrameUrl = UrlConfConstant.plcURL;
         } else if (DictionaryKey.INTERFACETYPE_AGV.equals(taskNode.getInterfaceType())) {
 //            autoProgrameUrl = parameterService.getValue(ParameterKey.AGVPROGRAMEURL, null);
-            autoProgrameUrl = agvURL;
+            autoProgrameUrl = UrlConfConstant.agvURL;
             //           autoProgrameUrl = url;
         } else if (DictionaryKey.INTERFACETYPE_WMS.equals(taskNode.getInterfaceType())) {
 //            autoProgrameUrl = parameterService.getValue(ParameterKey.AGVPROGRAMEURL, null);
             // autoProgrameUrl = agvURL;
-            autoProgrameUrl = url;
+            autoProgrameUrl = UrlConfConstant.url;
         }
         //正式调试的时候注释掉
-        autoProgrameUrl = url;
+        autoProgrameUrl = UrlConfConstant.url;
         return autoProgrameUrl;
     }
 

+ 36 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/dao/ProductionresourceBizMapper.java

@@ -0,0 +1,36 @@
+package com.github.zuihou.business.productionResourceCenter.dao;
+
+import com.github.zuihou.base.mapper.SuperMapper;
+import com.github.zuihou.tenant.entity.Productionresource;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ * Mapper 接口
+ * </p>
+ *
+ * @author imcs
+ * @date 2020-10-07
+ */
+@Repository
+public interface ProductionresourceBizMapper extends SuperMapper<Productionresource> {
+
+    List<Map> getList(Map map);
+
+
+    int getCount(Map map);
+
+
+    List<Map>getResourceStatus(Map map);
+
+    /**
+     * 获取设备和生产单元(产线)的关系
+     * @param map
+     * @return
+     */
+    List<Map>getResourceZone();
+
+}

+ 53 - 12
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/ProgramServiceImpl.java

@@ -2,7 +2,12 @@ package com.github.zuihou.business.productionResourceCenter.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.zuihou.business.DemoLine.DemoCacheKey;
+import com.github.zuihou.business.DemoLine.DemoLineConstant;
+import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourceBizMapper;
 import com.github.zuihou.business.productionResourceCenter.dao.ProgramMapper;
 import com.github.zuihou.business.productionResourceCenter.dto.ProgramSaveDTO;
 import com.github.zuihou.business.productionResourceCenter.dto.ProgramSuitProductionresourceSaveDTO;
@@ -16,20 +21,28 @@ import com.github.zuihou.base.service.SuperServiceImpl;
 
 import com.github.zuihou.business.productionResourceCenter.service.ProgramSuitProductionresourceService;
 import com.github.zuihou.common.constant.CodeRuleModule;
+import com.github.zuihou.common.constant.UrlConfConstant;
 import com.github.zuihou.context.BaseContextHandler;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.file.entity.Attachment;
 import com.github.zuihou.file.properties.FileServerProperties;
 import com.github.zuihou.file.service.AttachmentService;
+import com.github.zuihou.tenant.dao.ProductionresourceMapper;
+import com.github.zuihou.tenant.entity.Productionresource;
 import com.github.zuihou.tenant.service.CodeRuleService;
 import com.github.zuihou.utils.BeanPlusUtil;
+import com.google.common.collect.Maps;
 import com.xxl.job.core.log.XxlJobFileAppender;
 import com.xxl.job.core.util.FileUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.client.RestTemplate;
 
 import java.io.*;
 import java.nio.file.Paths;
@@ -39,6 +52,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 import static com.github.zuihou.utils.DateUtils.DEFAULT_MONTH_FORMAT_SLASH;
@@ -61,6 +75,12 @@ public class ProgramServiceImpl extends SuperServiceImpl<ProgramMapper, Program>
     CodeRuleService codeRuleService;
     @Autowired
     AttachmentService attachmentService;
+
+    @Autowired
+    private RestTemplate restTemplate;
+
+    @Autowired
+    ProductionresourceBizMapper productionresourceMapper;
     @Autowired
     protected FileServerProperties fileProperties;
 
@@ -72,21 +92,41 @@ public class ProgramServiceImpl extends SuperServiceImpl<ProgramMapper, Program>
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Program save(ProgramSaveDTO data) {
+        JSONObject jsonObject = new JSONObject();
+        //上传接口
+        Productionresource productionresource = productionresourceMapper.selectById(data.getResourceId());
+        List<Map<String, String>> fileList = new ArrayList<Map<String, String>>();
+        Map<String, String> m = new HashMap<>();
+//        m.put("fileName", data.getSubmittedFileName());
+        fileList.add(m);
+        jsonObject.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "uploadProgram");
+        jsonObject.put("Data", JSONArray.parseArray(JSONObject.toJSONString(fileList)));
+        jsonObject.put("url", productionresource.getIp());
+        jsonObject.put("port", productionresource.getPort());
+        jsonObject.put("BusinessType", "otheruploadProgram");
+        jsonObject.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "uploadProgram");
+        jsonObject.put("Data", JSONArray.parseArray(JSONObject.toJSONString(fileList)));
+
+        String jsonParam = jsonObject.toJSONString();
+
+        HttpHeaders headers = new HttpHeaders();
+        headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
+        HttpEntity<String> formEntity = new HttpEntity<String>(jsonParam, headers);
+        //调用接口
+        String returnData = restTemplate.postForObject(UrlConfConstant.plcURL, formEntity, String.class);
+
+
         Program program = BeanPlusUtil.toBean(data, Program.class);
         //根据编码规则
-        String no = codeRuleService.getBillCode(CodeRuleModule.CODE_RULE_PROGRAM);
-        program.setNo(no);
         save(program);
+        //
 
-        //新增适合设备
-        List<String> programSuitList = data.getProgramSuitList();
-        if(programSuitList !=null && programSuitList.size()>0){
-            for(String str:programSuitList){
-                ProgramSuitProductionresource item = new ProgramSuitProductionresource();
-                item.setProgramId(program.getId());
-                item.setResourceId(Long.parseLong(str));
-                programSuitProductionresourceService.save(item);
-            }
+        //设置程序数量
+        List<Program>programList = baseMapper.selectList(Wraps.<Program>lbQ().eq(Program::getResourceId,program.getResourceId()));
+
+        if(productionresource!=null){
+            productionresource.setProgramNum(programList.size());
+            productionresourceMapper.updateById(productionresource);
         }
         return program;
     }
@@ -175,7 +215,8 @@ public class ProgramServiceImpl extends SuperServiceImpl<ProgramMapper, Program>
             }
 
             //查询原始文件名,url
-            Attachment bean = attachmentService.getOne(Wraps.<Attachment>lbQ().eq(Attachment::getFilename,fileName));
+            List<Attachment> l = attachmentService.list(Wraps.<Attachment>lbQ().eq(Attachment::getFilename,fileName));
+            Attachment bean = l.get(0);
 
             map.put("content",sb.toString());
             map.put("runTime",(endTime - startTime));

+ 73 - 0
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/productionResourceCenter/ProductionresourceBizMapper.xml

@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.github.zuihou.business.productionResourceCenter.dao.ProductionresourceBizMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.github.zuihou.business.productionResourceCenter.entity.Productionresource">
+        <id column="id" jdbcType="BIGINT" property="id"/>
+        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+        <result column="create_user" jdbcType="BIGINT" property="createUser"/>
+        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
+        <result column="update_user" jdbcType="BIGINT" property="updateUser"/>
+        <result column="tenant_id" jdbcType="BIGINT" property="tenantId"/>
+        <result column="productionline_id" jdbcType="BIGINT" property="productionlineId"/>
+        <result column="box_id" jdbcType="BIGINT" property="boxId"/>
+        <result column="type" jdbcType="VARCHAR" property="type"/>
+        <result column="module_id" jdbcType="VARCHAR" property="moduleId"/>
+        <result column="name" jdbcType="VARCHAR" property="name"/>
+        <result column="code" jdbcType="VARCHAR" property="code"/>
+        <result column="status" jdbcType="VARCHAR" property="status"/>
+        <result column="remark" jdbcType="VARCHAR" property="remark"/>
+        <result column="resources_type" jdbcType="VARCHAR" property="resourcesType"/>
+        <result column="resources_category" jdbcType="VARCHAR" property="resourcesCategory"/>
+        <result column="ip" jdbcType="VARCHAR" property="ip"/>
+        <result column="port" jdbcType="VARCHAR" property="port"/>
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id,create_time,create_user,update_time,update_user,
+        tenant_id, productionline_id, box_id, type, category, module_id, name, code, status, remark, resources_type,resources_category,lineDesc,moduleDesc,tenantDesc,pic,
+        ip,port
+    </sql>
+
+    <!-- 分页 -->
+    <select id="pageList" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List"/>
+        from (
+        SELECT
+        a.*,b.name as lineDesc,c.name as moduleDesc,d.name as tenantDesc,c.pic,c.category
+        from imcs_tenant_productionresource a
+        left join imcs_tenant_productionline b on a.productionline_id = b.id
+        left join imcs_tenant_module c on a.module_id = c.id
+        left join d_tenant d on a.tenant_id = d.id
+        ) s ${ew.customSqlSegment}
+    </select>
+
+    <!-- 边缘盒子数据 -->
+    <select id="getModelList" parameterType="com.github.zuihou.tenant.entity.Productionresource"  resultType="com.github.zuihou.tenant.entity.Productionresource">
+        SELECT * from imcs_tenant_productionresource
+        WHERE type = #{type}
+    </select>
+
+    <update id="createDynTable" parameterType="java.util.Map">
+        ${sql}
+    </update>
+
+    <!-- 检测数据库 -->
+    <select id="checkDatabase" parameterType="String" resultType="int">
+          ${sql}
+    </select>
+
+    <!-- 检测数据库 -->
+    <select id="checkTable" parameterType="String" resultType="int">
+          ${sql}
+    </select>
+
+    <select id="selectSql" parameterType="String" resultType="map">
+          ${sql}
+    </select>
+
+
+</mapper>

+ 319 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/productionResourceCenter/entity/Productionresource.java

@@ -0,0 +1,319 @@
+package com.github.zuihou.business.productionResourceCenter.entity;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.github.zuihou.base.entity.Entity;
+import com.github.zuihou.common.constant.DictionaryType;
+import com.github.zuihou.injection.annonation.InjectionField;
+import com.github.zuihou.model.RemoteData;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.*;
+import lombok.experimental.Accessors;
+import org.hibernate.validator.constraints.Length;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
+import static com.github.zuihou.common.constant.InjectionFieldConstants.DICTIONARY_ITEM_CLASS;
+import static com.github.zuihou.common.constant.InjectionFieldConstants.DICTIONARY_ITEM_METHOD;
+
+/**
+ * <p>
+ * 实体类
+ * 生产资源、边缘盒子表
+ * </p>
+ *
+ * @author imcs
+ * @since 2020-10-13
+ */
+@Data
+@NoArgsConstructor
+@ToString(callSuper = true)
+@EqualsAndHashCode(callSuper = true)
+@Accessors(chain = true)
+@TableName("imcs_tenant_productionresource")
+@ApiModel(value = "Productionresource", description = "生产资源、边缘盒子表")
+@AllArgsConstructor
+public class Productionresource extends Entity<Long> {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 企业ID
+     */
+    @ApiModelProperty(value = "企业ID")
+    @TableField("tenant_id")
+    @Excel(name = "企业ID")
+    private Long tenantId;
+
+    /**
+     * 产线ID
+     */
+    @ApiModelProperty(value = "产线ID")
+    @TableField("productionline_id")
+    @Excel(name = "产线ID")
+    private Long productionlineId;
+
+    /**
+     * 边缘盒子Id(当类型是生产资源得时候)
+     */
+    @ApiModelProperty(value = "边缘盒子Id(当类型是生产资源得时候)")
+    @TableField("box_id")
+    @Excel(name = "边缘盒子Id(当类型是生产资源得时候)")
+    private Long boxId;
+
+    /**
+     * 类型(1-边缘盒子2-生产资源)
+     */
+    @ApiModelProperty(value = "类型(1-边缘盒子2-生产资源)")
+    @Length(max = 4, message = "类型(1-边缘盒子2-生产资源)长度不能超过4")
+    @TableField(value = "type", condition = LIKE)
+    @InjectionField(api = DICTIONARY_ITEM_CLASS, method = DICTIONARY_ITEM_METHOD, dictType = DictionaryType.RESOURCES_TYPE)
+    @Excel(name = "类型(1-边缘盒子2-生产资源)")
+    private RemoteData<String, String> type;
+
+    /**
+     * 分类
+     */
+    @ApiModelProperty(value = "分类")
+    @Length(max = 4, message = "分类长度不能超过4")
+    @TableField(exist=false)
+    @InjectionField(api = DICTIONARY_ITEM_CLASS, method = DICTIONARY_ITEM_METHOD, dictType = DictionaryType.RESOURCES_CATEGORY)
+    @ExcelEntity(name = "category")
+    @Excel(name = "分类")
+    private RemoteData<String, String> category;
+
+    /**
+     * 模块ID
+     */
+    @ApiModelProperty(value = "模块ID")
+    @Length(max = 32, message = "模块ID长度不能超过32")
+    @TableField(value = "module_id", condition = LIKE)
+    @Excel(name = "模块ID")
+    private String moduleId;
+
+    /**
+     * 名称
+     */
+    @ApiModelProperty(value = "名称")
+    @Length(max = 256, message = "名称长度不能超过256")
+    @TableField(value = "name", condition = LIKE)
+    @Excel(name = "名称")
+    private String name;
+
+    /**
+     * 编号
+     */
+    @ApiModelProperty(value = "编号")
+    @Length(max = 32, message = "编号长度不能超过32")
+    @TableField(value = "code", condition = LIKE)
+    @Excel(name = "编号")
+    private String code;
+
+    /**
+     * 在线状态(0-离线1-在线2-未激活)
+     */
+    @ApiModelProperty(value = "在线状态(0-离线1-在线2-未激活)")
+    @Length(max = 4, message = "在线状态(0-离线1-在线2-未激活)长度不能超过4")
+    @TableField(value = "online_status", condition = LIKE)
+    @Excel(name = "在线状态(0-离线1-在线2-未激活)")
+    private String onlineStatus;
+
+    /**
+     * 状态(1-启用0-停用)
+     */
+    @ApiModelProperty(value = "状态(1-启用0-停用)")
+    @Length(max = 4, message = "状态(1-启用0-停用)长度不能超过4")
+    @TableField(value = "status", condition = LIKE)
+    @Excel(name = "状态(1-启用0-停用)")
+    private String status;
+
+    /**
+     * 资产编号
+     */
+    @ApiModelProperty(value = "资产编号")
+    @Length(max = 32, message = "资产编号长度不能超过32")
+    @TableField(value = "capital_no", condition = LIKE)
+    @Excel(name = "资产编号")
+    private String capitalNo;
+
+    /**
+     * 资产名称
+     */
+    @ApiModelProperty(value = "资产名称")
+    @Length(max = 256, message = "资产名称长度不能超过256")
+    @TableField(value = "capital_name", condition = LIKE)
+    @Excel(name = "资产名称")
+    private String capitalName;
+
+    /**
+     * 资产类别
+     */
+    @ApiModelProperty(value = "资产类别")
+    @Length(max = 10, message = "资产类别长度不能超过10")
+    @TableField(value = "capital_type", condition = LIKE)
+    @Excel(name = "资产名称")
+    private String capitalType;
+
+    /**
+     * 型号规格
+     */
+    @ApiModelProperty(value = "型号规格")
+    @Length(max = 256, message = "型号规格长度不能超过256")
+    @TableField(value = "mode_specification", condition = LIKE)
+    @Excel(name = "型号规格")
+    private String modeSpecification;
+
+    /**
+     * 资产原值
+     */
+    @ApiModelProperty(value = "资产原值")
+    @Length(max = 256, message = "资产原值长度不能超过256")
+    @TableField(value = "capital_price", condition = LIKE)
+    @Excel(name = "资产原值")
+    private String capitalPrice;
+
+    /**
+     * 出厂年月
+     */
+    @ApiModelProperty(value = "出厂年月")
+    @Length(max = 256, message = "出厂年月长度不能超过256")
+    @TableField(value = "production_date", condition = LIKE)
+    @Excel(name = "出厂年月")
+    private String productionDate;
+
+    /**
+     * 出厂编号
+     */
+    @ApiModelProperty(value = "出厂编号")
+    @Length(max = 256, message = "出厂编号长度不能超过256")
+    @TableField(value = "production_no", condition = LIKE)
+    @Excel(name = "出厂编号")
+    private String productionNo;
+
+    /**
+     * 制造厂家
+     */
+    @ApiModelProperty(value = "制造厂家")
+    @Length(max = 256, message = "出厂编号长度不能超过256")
+    @TableField(value = "manufacturer", condition = LIKE)
+    @Excel(name = "制造厂家")
+    private String manufacturer;
+
+    /**
+     * 备注
+     */
+    @ApiModelProperty(value = "备注")
+    @Length(max = 256, message = "备注长度不能超过256")
+    @TableField(value = "remark", condition = LIKE)
+    @Excel(name = "备注")
+    private String remark;
+
+    /**
+     * 生产资源类型(1-企业管理中的 2-全部资源管理)
+     */
+    @ApiModelProperty(value = "生产资源类型(1-企业管理中的 2-全部资源管理)")
+    @Length(max = 4, message = "生产资源类型(1-企业管理中的 2-全部资源管理)长度不能超过4")
+    @TableField(value = "resources_type", condition = LIKE)
+    @Excel(name = "生产资源类型(1-企业管理中的 2-全部资源管理)")
+    private String resourcesType;
+
+    /**
+     * 生产资源种类(1-基础机器类 2-ARV搬运类 3-机器人操作类)
+     */
+    @ApiModelProperty(value = "生产资源种类(1-基础机器类 2-ARV搬运类 3-机器人操作类)")
+    @Length(max = 4, message = "生产资源种类(1-基础机器类 2-ARV搬运类 3-机器人操作类)长度不能超过4")
+    @TableField(value = "resources_category", condition = LIKE)
+    @Excel(name = "生产资源种类(1-基础机器类 2-ARV搬运类 3-机器人操作类)")
+    private String resourcesCategory;
+
+    /**
+     * IP
+     */
+    @ApiModelProperty(value = "IP")
+    @Length(max = 4, message = "IP 长度不能超过64")
+    @TableField(value = "ip", condition = LIKE)
+    @Excel(name = "IP")
+    private String ip;
+    /**
+     * 端口号
+     */
+    @ApiModelProperty(value = "端口号")
+    @Length(max = 4, message = "端口号 长度不能超过32")
+    @TableField(value = "port", condition = LIKE)
+    @Excel(name = "端口号")
+    private String port;
+
+    @ApiModelProperty(value = "产线名称")
+    @TableField(exist=false)
+    private String lineDesc;
+
+    @ApiModelProperty(value = "模型名称")
+    @TableField(exist=false)
+    private String moduleDesc;
+
+    @ApiModelProperty(value = "企业名称")
+    @TableField(exist=false)
+    private String tenantDesc;
+
+    @ApiModelProperty(value = "字段")
+    @TableField(exist=false)
+    private String field;
+
+    @ApiModelProperty(value = "图片")
+    @TableField(exist=false)
+    private String pic;
+
+    @ApiModelProperty(value = "采集任务ID")
+    @TableField("GATHER_TASK_ID")
+    private int gatherTaskId;
+
+    @ApiModelProperty(value = "手爪数量")
+    @TableField("hand_num")
+    private Integer handNum;
+    @ApiModelProperty(value = "工作台数量")
+    @TableField("workbench_num")
+    private Integer workbenchNum;
+    @ApiModelProperty(value = "缓存库数量")
+    @TableField("cache_storge_num")
+    private Integer cacheStorgeNum;
+    @ApiModelProperty(value = "最大移动速度")
+    @TableField("max_speed")
+    private Float maxSpeed;
+    @ApiModelProperty(value = "可放子盘数量")
+    @TableField("tray_num")
+    private Integer trayNum;
+
+
+
+
+    @Builder
+    public Productionresource(Long id, LocalDateTime createTime, Long createUser, LocalDateTime updateTime, Long updateUser,
+                              Long tenantId, Long productionlineId, Long boxId, RemoteData<String, String> type, RemoteData<String, String>  category,
+                              String moduleId, String name, String code, String status, String remark, String resourcesType, String onlineStatus, String ip, String port) {
+        this.id = id;
+        this.createTime = createTime;
+        this.createUser = createUser;
+        this.updateTime = updateTime;
+        this.updateUser = updateUser;
+        this.tenantId = tenantId;
+        this.productionlineId = productionlineId;
+        this.boxId = boxId;
+        this.type = type;
+        this.category = category;
+        this.moduleId = moduleId;
+        this.name = name;
+        this.code = code;
+        this.status = status;
+        this.remark = remark;
+        this.resourcesType = resourcesType;
+        this.onlineStatus = onlineStatus;
+        this.ip = ip;
+        this.port = port;
+    }
+
+}

+ 28 - 0
imcs-admin-boot/imcs-common/src/main/java/com/github/zuihou/common/constant/UrlConfConstant.java

@@ -0,0 +1,28 @@
+package com.github.zuihou.common.constant;
+
+/**
+ * 业务常量
+ *
+ * @author zuihou
+ * @date 2019/08/06
+ */
+public interface UrlConfConstant {
+
+
+        public String url = "http://127.0.0.1:8764/task/testTask";
+
+        public String plcURL = "http://192.168.170.202:8089";
+
+        public String agvURL = "http://localhost:9099/api/authority/mock/mockWms";
+        //质量中心
+        public String ZK_ip_zlzx = "192.168.170.61";
+        //柔性
+        public String ZK_ip_rxx = "192.168.170.71";
+        //智能单元
+        public String ZK_ip_zndy = "192.168.170.81";
+
+        //总控端口
+        public String ZK_port = "120";
+
+
+}

+ 10 - 5
imcs-admin-boot/imcs-file-biz/src/main/java/com/github/zuihou/file/service/impl/AttachmentServiceImpl.java

@@ -87,11 +87,16 @@ public class AttachmentServiceImpl extends SuperServiceImpl<AttachmentMapper, At
             DatabaseProperties.Id idPro = databaseProperties.getId();
             bizId = IdUtil.getSnowflake(idPro.getWorkerId(), idPro.getDataCenterId()).nextIdStr();
         }
-        File file = fileStrategy.upload(multipartFile);
-        //TODO
-        //将程序通过FTP传递一份
-        boolean flag = ftpProperties.upload(multipartFile.getInputStream(),multipartFile.getOriginalFilename());
-        Assert.isFalse(flag,"通过Ftp传输程序文件失败!");
+        File file = null;
+        if("PROGRAM".equals(bizType)){
+            file = fileStrategy.uploadOriFileName(multipartFile);
+            //将程序通过FTP传递一份
+            boolean flag = ftpProperties.upload(multipartFile.getInputStream(),multipartFile.getOriginalFilename());
+            Assert.isFalse(flag,"通过Ftp传输程序文件失败!");
+        }else{
+            fileStrategy.upload(multipartFile);
+        }
+
 
         Attachment attachment = BeanPlusUtil.toBean(file, Attachment.class);
 

+ 2 - 0
imcs-admin-boot/imcs-file-biz/src/main/java/com/github/zuihou/file/strategy/FileStrategy.java

@@ -23,6 +23,8 @@ public interface FileStrategy {
      */
     File upload(MultipartFile file);
 
+    File uploadOriFileName(MultipartFile file);
+
     /**
      * 删除源文件
      *

+ 59 - 0
imcs-admin-boot/imcs-file-biz/src/main/java/com/github/zuihou/file/strategy/impl/AbstractFileStrategy.java

@@ -1,5 +1,7 @@
 package com.github.zuihou.file.strategy.impl;
 
+import cn.hutool.core.util.StrUtil;
+import com.github.zuihou.context.BaseContextHandler;
 import com.github.zuihou.exception.BizException;
 import com.github.zuihou.file.domain.FileDeleteDO;
 import com.github.zuihou.file.entity.File;
@@ -8,15 +10,21 @@ import com.github.zuihou.file.properties.FileServerProperties;
 import com.github.zuihou.file.strategy.FileStrategy;
 import com.github.zuihou.file.utils.FileDataTypeUtil;
 import com.github.zuihou.utils.DateUtils;
+import com.github.zuihou.utils.StrPool;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.io.FilenameUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.nio.file.Paths;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.List;
+import java.util.UUID;
 
 import static com.github.zuihou.exception.code.ExceptionCode.BASE_VALID_PARAM;
+import static com.github.zuihou.utils.DateUtils.DEFAULT_MONTH_FORMAT_SLASH;
 
 
 /**
@@ -62,6 +70,57 @@ public abstract class AbstractFileStrategy implements FileStrategy {
         }
     }
 
+    @Override
+    public File uploadOriFileName(MultipartFile multipartFile) {
+        try {
+            if (!multipartFile.getOriginalFilename().contains(FILE_SPLIT)) {
+                throw BizException.wrap(BASE_VALID_PARAM.build("缺少后缀名"));
+            }
+
+            File file = File.builder()
+                    .isDelete(false).submittedFileName(multipartFile.getOriginalFilename())
+                    .contextType(multipartFile.getContentType())
+                    .dataType(FileDataTypeUtil.getDataType(multipartFile.getContentType()))
+                    .size(multipartFile.getSize())
+                    .ext(FilenameUtils.getExtension(multipartFile.getOriginalFilename()))
+                    .build();
+            file.setIcon(IconType.getIcon(file.getExt()).getIcon());
+            setDate(file);
+
+
+
+            //根据原名
+            String fileName = multipartFile.getOriginalFilename();
+
+            String tenant = BaseContextHandler.getTenant();
+
+            //日期文件夹
+            String relativePath = Paths.get(tenant, LocalDate.now().format(DateTimeFormatter.ofPattern(DEFAULT_MONTH_FORMAT_SLASH))).toString();
+            // web服务器存放的绝对路径
+            String absolutePath = Paths.get(fileProperties.getStoragePath(), relativePath).toString();
+
+            java.io.File outFile = new java.io.File(Paths.get(absolutePath, fileName).toString());
+            org.apache.commons.io.FileUtils.writeByteArrayToFile(outFile, multipartFile.getBytes());
+
+            String url = new StringBuilder(fileProperties.getUriPrefix())
+                    .append(relativePath)
+                    .append(StrPool.SLASH)
+                    .append(fileName)
+                    .toString();
+            //替换掉windows环境的\路径
+            url = StrUtil.replace(url, "\\\\", StrPool.SLASH);
+            url = StrUtil.replace(url, "\\", StrPool.SLASH);
+            file.setUrl(url);
+            file.setFilename(fileName);
+            file.setRelativePath(relativePath);
+
+            return file;
+        } catch (Exception e) {
+            log.error("e={}", e);
+            throw BizException.wrap(BASE_VALID_PARAM.build("文件上传失败"));
+        }
+    }
+
     /**
      * 具体类型执行上传操作
      *

+ 20 - 0
imcs-admin-boot/imcs-file-controller/src/main/java/com/github/zuihou/file/controller/AttachmentController.java

@@ -103,6 +103,26 @@ public class AttachmentController extends SuperSimpleController<AttachmentServic
         return R.success(attachment);
     }
 
+    @PostMapping(value = "/uploadOriFileName")
+    @SysLog("上传附件,上传附件名为原名")
+    public R<AttachmentDTO> uploadOriFileName (
+            @RequestParam(value = "file") MultipartFile file,
+            @RequestParam(value = "isSingle", required = false, defaultValue = "false") Boolean isSingle,
+            @RequestParam(value = "id", required = false) Long id,
+            @RequestParam(value = "bizId", required = false) String bizId,
+            @RequestParam(value = "bizType", required = false) String bizType) throws Exception{
+        BizAssert.notEmpty(bizType, BASE_VALID_PARAM.build("业务类型不能为空"));
+        // 忽略路径字段,只处理文件类型
+        if (file.isEmpty()) {
+            return R.fail(BASE_VALID_PARAM.build("请求中必须至少包含一个有效文件"));
+        }
+        String tenant = BaseContextHandler.getTenant();
+
+        AttachmentDTO attachment = baseService.upload(file, tenant, id, bizType, bizId, isSingle);
+
+        return R.success(attachment);
+    }
+
 
     @ApiOperation(value = "根据业务类型或业务id删除文件", notes = "根据业务类型或业务id删除文件")
     @DeleteMapping(value = "/biz")

+ 5 - 0
imcs-admin-boot/imcs-tenant-entity/src/main/java/com/github/zuihou/tenant/entity/Productionresource.java

@@ -289,6 +289,11 @@ public class Productionresource extends Entity<Long> {
     private Integer trayNum;
 
 
+    @ApiModelProperty(value = "程序数量")
+    @TableField("program_num")
+    private Integer programNum;
+
+
     @TableField(exist = false)
     private List<ModuleInstruction> instructionList;