5 vuotta sitten
vanhempi
commit
465b9b1100

+ 12 - 0
pcbms/src/main/java/com/hssx/pcbms/constant/Constant.java

@@ -0,0 +1,12 @@
+package com.hssx.pcbms.constant;
+
+/**
+ * Author: 吴涛涛
+ * Date : 2019 - 07 - 24 16:00
+ * Description:<描述>常量配置类
+ * Version: 1.0
+ */
+public class Constant {
+    public static final String HANDLE_CONTENT = "将状态 oldState 改为 newState ";//处理资产类容前缀
+
+}

+ 15 - 0
pcbms/src/main/java/com/hssx/pcbms/controller/GoodsController.java

@@ -119,5 +119,20 @@ public class GoodsController {
         return msg;
     }
 
+    /**
+     * 处置资产
+     * 参数:
+     * id:对应编号的id,state:资产状态0-空闲 1-在用 2-维护 3-报废
+     * userId :对应人员的id(不选传0)
+     * @return
+     */
+    @ApiOperation(value = "处置资产", notes = "处置资产方法")
+    @RequestMapping("/handle")
+    @ResponseBody
+    public HttpRespMsg handle(GoodsNo goodsNo,Integer currentUserId) {
+        HttpRespMsg msg = goodsService.handle(goodsNo,currentUserId);
+        return msg;
+    }
+
 }
 

+ 10 - 0
pcbms/src/main/java/com/hssx/pcbms/controller/OperaterRecordController.java

@@ -1,10 +1,18 @@
 package com.hssx.pcbms.controller;
 
 
+import com.hssx.pcbms.entity.GoodsNo;
+import com.hssx.pcbms.entity.vo.GoodsVO;
+import com.hssx.pcbms.util.HttpRespMsg;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
 
 /**
  * @author 吴涛涛
@@ -14,5 +22,7 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("/operaterrecord")
 public class OperaterRecordController {
 
+
+
 }
 

+ 16 - 1
pcbms/src/main/java/com/hssx/pcbms/entity/Goods.java

@@ -12,7 +12,7 @@ import java.io.Serializable;
  * </p>
  *
  * @author 吴涛涛
- * @since 2019-10-28
+ * @since 2019-10-29
  */
 public class Goods extends Model<Goods> {
 
@@ -84,6 +84,12 @@ public class Goods extends Model<Goods> {
     @TableField("is_delete")
     private Integer isDelete;
 
+    /**
+     * 录入人id
+     */
+    @TableField("creator_id")
+    private Integer creatorId;
+
 
     public Integer getId() {
         return id;
@@ -173,6 +179,14 @@ public class Goods extends Model<Goods> {
         this.isDelete = isDelete;
     }
 
+    public Integer getCreatorId() {
+        return creatorId;
+    }
+
+    public void setCreatorId(Integer creatorId) {
+        this.creatorId = creatorId;
+    }
+
     @Override
     protected Serializable pkVal() {
         return this.id;
@@ -192,6 +206,7 @@ public class Goods extends Model<Goods> {
         ", serviceLife=" + serviceLife +
         ", nextIndate=" + nextIndate +
         ", isDelete=" + isDelete +
+        ", creatorId=" + creatorId +
         "}";
     }
 }

+ 3 - 0
pcbms/src/main/java/com/hssx/pcbms/entity/GoodsNo.java

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.baomidou.mybatisplus.annotation.TableId;
 import java.time.LocalDateTime;
 import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
 import java.io.Serializable;
 
 /**
@@ -53,6 +55,7 @@ public class GoodsNo extends Model<GoodsNo> {
      * 创建日期
      */
     @TableField("indate")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime indate;
 
     /**

+ 16 - 4
pcbms/src/main/java/com/hssx/pcbms/entity/OperaterRecord.java

@@ -5,8 +5,6 @@ import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.baomidou.mybatisplus.annotation.TableId;
 import java.time.LocalDateTime;
 import com.baomidou.mybatisplus.annotation.TableField;
-import com.fasterxml.jackson.annotation.JsonFormat;
-
 import java.io.Serializable;
 
 /**
@@ -15,7 +13,7 @@ import java.io.Serializable;
  * </p>
  *
  * @author 吴涛涛
- * @since 2019-10-25
+ * @since 2019-10-29
  */
 public class OperaterRecord extends Model<OperaterRecord> {
 
@@ -43,7 +41,6 @@ public class OperaterRecord extends Model<OperaterRecord> {
      * 操作时间
      */
     @TableField("indate")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime indate;
 
     /**
@@ -64,6 +61,12 @@ public class OperaterRecord extends Model<OperaterRecord> {
     @TableField("good_no")
     private String goodNo;
 
+    /**
+     * 资产状态0-空闲 1-在用 2-维护 3-报废
+     */
+    @TableField("good_state")
+    private Integer goodState;
+
 
     public Integer getId() {
         return id;
@@ -121,6 +124,14 @@ public class OperaterRecord extends Model<OperaterRecord> {
         this.goodNo = goodNo;
     }
 
+    public Integer getGoodState() {
+        return goodState;
+    }
+
+    public void setGoodState(Integer goodState) {
+        this.goodState = goodState;
+    }
+
     @Override
     protected Serializable pkVal() {
         return this.id;
@@ -136,6 +147,7 @@ public class OperaterRecord extends Model<OperaterRecord> {
         ", content=" + content +
         ", goodId=" + goodId +
         ", goodNo=" + goodNo +
+        ", goodState=" + goodState +
         "}";
     }
 }

+ 2 - 0
pcbms/src/main/java/com/hssx/pcbms/service/GoodsService.java

@@ -29,4 +29,6 @@ public interface GoodsService extends IService<Goods> {
     HttpRespMsg delNo(GoodsNo goodsNo);
 
     HttpRespMsg getDetail(Integer id);
+
+    HttpRespMsg handle(GoodsNo goodsNo,Integer currentUserId);
 }

+ 50 - 17
pcbms/src/main/java/com/hssx/pcbms/service/impl/GoodsServiceImpl.java

@@ -3,11 +3,16 @@ package com.hssx.pcbms.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.hssx.pcbms.constant.Constant;
 import com.hssx.pcbms.entity.Goods;
 import com.hssx.pcbms.entity.GoodsNo;
+import com.hssx.pcbms.entity.OperaterRecord;
+import com.hssx.pcbms.entity.User;
 import com.hssx.pcbms.entity.vo.GoodsVO;
 import com.hssx.pcbms.mapper.GoodsMapper;
 import com.hssx.pcbms.mapper.GoodsNoMapper;
+import com.hssx.pcbms.mapper.OperaterRecordMapper;
+import com.hssx.pcbms.mapper.UserMapper;
 import com.hssx.pcbms.service.GoodsNoService;
 import com.hssx.pcbms.service.GoodsService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -20,12 +25,13 @@ import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
+import java.net.ConnectException;
 import java.util.ArrayList;
 import java.util.List;
 
 /**
  * <p>
- *  服务实现类
+ * 服务实现类
  * </p>
  *
  * @author 吴涛涛
@@ -41,35 +47,39 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
     private GoodsNoService goodsNoService;
     @Value("${upload.path}")
     private String path;
+    @Resource
+    private OperaterRecordMapper operaterRecordMapper;
+    @Resource
+    private UserMapper userMapper;
 
     @Override
-    public HttpRespMsg add(GoodsVO goodsVO,MultipartFile file) {
+    public HttpRespMsg add(GoodsVO goodsVO, MultipartFile file) {
         HttpRespMsg msg = new HttpRespMsg();
-        if(null != file){
+        if (null != file) {
             goodsVO.setPic(UploadFileToFileNameUtil.uploadFile(file, path));
         }
         Goods goods = new Goods();
-        BeanUtils.copyProperties(goodsVO,goods);
+        BeanUtils.copyProperties(goodsVO, goods);
         List<GoodsNo> list = new ArrayList<>();
+        goods.setCreatorId(goodsVO.getUserId());
         goodsMapper.insert(goods);
-        String mouldNo = goodsVO.getDeptStr()+goodsVO.getGoodStr();
-        Integer count = goodsNoMapper.selectCount(new QueryWrapper<GoodsNo>().eq("division_code",goodsVO.getDeptStr()).eq("suffix_code",goodsVO.getGoodStr()).last("limit 1"));
-        if(count>0){
+        String mouldNo = goodsVO.getDeptStr() + goodsVO.getGoodStr();
+        Integer count = goodsNoMapper.selectCount(new QueryWrapper<GoodsNo>().eq("division_code", goodsVO.getDeptStr()).eq("suffix_code", goodsVO.getGoodStr()).last("limit 1"));
+        if (count > 0) {
             msg.setError("当前编号组合已存在,请更换编号组合后重试。");
             return msg;
         }
-        if(0 != goodsVO.getNumber()){
-            for(int i=0;i<goodsVO.getNumber();i++){
+        if (0 != goodsVO.getNumber()) {
+            for (int i = 0; i < goodsVO.getNumber(); i++) {
                 GoodsNo goodsNo = new GoodsNo();
                 goodsNo.setGoodsId(goods.getId());
-                goodsNo.setModelNo(mouldNo+String.format("%04d", i));
+                goodsNo.setModelNo(mouldNo + String.format("%04d", i));
                 goodsNo.setSuffixCode(goodsVO.getGoodStr());
                 goodsNo.setDivisionCode(goodsVO.getDeptStr());
-                goodsNo.setUserId(goodsVO.getUserId());
                 list.add(goodsNo);
             }
             goodsNoService.saveBatch(list);
-        }else{
+        } else {
             msg.setError("资产数量必须大于零");
         }
         return msg;
@@ -78,7 +88,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
     @Override
     public HttpRespMsg updateInfo(Goods goods, MultipartFile file) {
         HttpRespMsg msg = new HttpRespMsg();
-        if(null != file){
+        if (null != file) {
             goods.setPic(UploadFileToFileNameUtil.uploadFile(file, path));
         }
         goodsMapper.updateById(goods);
@@ -88,8 +98,8 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
     @Override
     public HttpRespMsg getList(PageUtil page, String keyName, Integer tagId) {
         HttpRespMsg msg = new HttpRespMsg();
-        PageHelper.startPage(page.getPageNum(),page.getPageSize());
-        List<GoodsVO> list = goodsMapper.getListBycondition(keyName,tagId);
+        PageHelper.startPage(page.getPageNum(), page.getPageSize());
+        List<GoodsVO> list = goodsMapper.getListBycondition(keyName, tagId);
         PageInfo<GoodsVO> info = new PageInfo<>(list);
         msg.data = info;
         return msg;
@@ -107,9 +117,9 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
     public HttpRespMsg delNo(GoodsNo goodsNo) {
         HttpRespMsg msg = new HttpRespMsg();
         GoodsNo no = goodsNoMapper.selectById(goodsNo.getId());
-        if(no != null && no.getState()==0){
+        if (no != null && no.getState() == 0) {
             goodsNoMapper.deleteById(goodsNo.getId());
-        }else{
+        } else {
             msg.setError("操作失败,该id对应的资产不存在或者处于非空闲状态。");
         }
         return msg;
@@ -123,6 +133,29 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
         return msg;
     }
 
+    @Override
+    public HttpRespMsg handle(GoodsNo goodsNo,Integer currentUserId) {
+        HttpRespMsg msg = new HttpRespMsg();
+        User user = userMapper.selectById(currentUserId);
+        GoodsNo no = goodsNoMapper.selectById(goodsNo.getId());
+        goodsNoMapper.updateById(goodsNo);
+        //添加处置记录
+        OperaterRecord operaterRecord = new OperaterRecord();
+//        if(1==goodsNo.getState()){
+//
+//        }else if(){
+//
+//        }
+//        String content = Constant.HANDLE_CONTENT.replace("oldState",)
+//        operaterRecord.setContent();
+        operaterRecord.setGoodId(no.getGoodsId());
+        operaterRecord.setGoodNo(no.getModelNo());
+        operaterRecord.setGoodState(goodsNo.getState());
+        operaterRecord.setUserId(currentUserId);
+        operaterRecord.setUserName(user.getName());
+        return null;
+    }
+
     public static void main(String[] args) {
         String format = String.format("%04d", 0);
         System.out.println(format);

+ 1 - 1
pcbms/src/main/java/com/hssx/pcbms/util/CodeGenerator.java

@@ -204,7 +204,7 @@ public class CodeGenerator {
         //若想要生成的实体类继承某个Controller,则可打开下面注释。写上需要继承的Controller的位置即可
 //        strategy.setSuperControllerClass("com.baomidou.ant.common.BaseController");
         //此处user是表名,多个英文逗号分割
-        strategy.setInclude("goods","goods_no");
+        strategy.setInclude("operater_record");
 //        strategy.setExclude();//数据库表全生成
 //        strategy.setInclude(scanner("user").split(","));//表名,多个英文逗号分割
         strategy.setControllerMappingHyphenStyle(true);

+ 6 - 5
pcbms/src/main/resources/mapper/GoodsMapper.xml

@@ -15,11 +15,12 @@
         <result column="service_life" property="serviceLife" />
         <result column="next_indate" property="nextIndate" />
         <result column="is_delete" property="isDelete" />
+        <result column="creator_id" property="creatorId" />
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, name, tag_id, model_number, unit, address, factory, pic, service_life, next_indate, is_delete
+        id, name, tag_id, model_number, unit, address, factory, pic, service_life, next_indate, is_delete, creator_id
     </sql>
 
     <!-- 通用查询映射结果 -->
@@ -53,9 +54,9 @@
         g.id, g.name, g.tag_id, g.model_number, g.unit,gn.id nid,
         gn.model_no, gn.division_code, gn.suffix_code, gn.state, gn.indate, gn.goods_id, gn.user_id
         from
-            goods g
+        goods g
         left join
-            goods_no gn
+        goods_no gn
         on g.id = gn.goods_id
         <where>
             is_delete = 0
@@ -72,9 +73,9 @@
         g.id, g.name, g.tag_id, g.model_number, g.unit,g.address, g.factory, g.pic, g.service_life, g.next_indate, g.is_delete,gn.id nid,
         gn.model_no, gn.division_code, gn.suffix_code, gn.state, gn.indate, gn.goods_id, gn.user_id
         from
-            goods g
+        goods g
         left join
-            goods_no gn
+        goods_no gn
         on g.id = gn.goods_id
         <where>
             g.id = #{id}

+ 2 - 1
pcbms/src/main/resources/mapper/OperaterRecordMapper.xml

@@ -11,11 +11,12 @@
         <result column="content" property="content" />
         <result column="good_id" property="goodId" />
         <result column="good_no" property="goodNo" />
+        <result column="good_state" property="goodState" />
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, user_id, user_name, indate, content, good_id, good_no
+        id, user_id, user_name, indate, content, good_id, good_no, good_state
     </sql>
 
 </mapper>