فهرست منبع

资产编号的处理,详情与处理资产记录

5 سال پیش
والد
کامیت
3eec914c82

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

@@ -148,7 +148,33 @@ public class GoodsController {
         return msg;
     }
 
+    /**
+     * 资产编号删除
+     * 参数:
+     * id:对应编号的id
+     * @return
+     */
+    @ApiOperation(value = "资产编号删除", notes = "资产编号删除方法")
+    @RequestMapping("/goodsNodel")
+    @ResponseBody
+    public HttpRespMsg goodsNodel(GoodsNo goodsNo) {
+        HttpRespMsg msg = goodsService.goodsNodel(goodsNo);
+        return msg;
+    }
 
+    /**
+     * 资产编号添加
+     * 参数:
+     * id:资产的goodId
+     * @return
+     */
+    @ApiOperation(value = "资产编号添加", notes = "资产编号添加方法")
+    @RequestMapping("/goodsNoAdd")
+    @ResponseBody
+    public HttpRespMsg goodsNoAdd(GoodsNo goodsNo,Integer count) {
+        HttpRespMsg msg = goodsService.goodsNoAdd(goodsNo,count);
+        return msg;
+    }
 
     /**
      * 处置资产操作记录

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

@@ -35,4 +35,8 @@ public interface GoodsService extends IService<Goods> {
     HttpRespMsg operateList(Goods goods);
 
     HttpRespMsg goodsNoDetailById(GoodsNo goodsNo);
+
+    HttpRespMsg goodsNodel(GoodsNo goodsNo);
+
+    HttpRespMsg goodsNoAdd(GoodsNo goodsNo,Integer count);
 }

+ 57 - 21
pcbms/src/main/java/com/hssx/pcbms/service/impl/GoodsServiceImpl.java

@@ -23,6 +23,7 @@ import com.hssx.pcbms.util.UploadFileToFileNameUtil;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
@@ -97,9 +98,9 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
 
     @Override
     public HttpRespMsg getList(PageUtil page, String keyName, Integer tagId) {
-        System.out.println("页数:"+page.getPageNum());
+        System.out.println("页数:" + page.getPageNum());
         HttpRespMsg msg = new HttpRespMsg();
-        PageHelper.startPage(page.getPageNum(),page.getPageSize());
+        PageHelper.startPage(page.getPageNum(), page.getPageSize());
         List<GoodsVO> list = goodsMapper.getListBycondition(keyName, tagId);
         PageInfo<GoodsVO> info = new PageInfo<>(list);
         msg.data = info;
@@ -135,7 +136,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
     }
 
     @Override
-    public HttpRespMsg handle(GoodsNo goodsNo,Integer currentUserId) {
+    public HttpRespMsg handle(GoodsNo goodsNo, Integer currentUserId) {
         HttpRespMsg msg = new HttpRespMsg();
         User user = userMapper.selectById(currentUserId);
         GoodsNo no = goodsNoMapper.selectById(goodsNo.getId());
@@ -144,23 +145,23 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
         OperateRecord operateRecord = new OperateRecord();
         String oldState = "";
         String nowState = "";
-        if(no.getState()==0){
-             oldState="未用";
-        }else if(no.getState()==1){
-            oldState="在用";
+        if (no.getState() == 0) {
+            oldState = "未用";
+        } else if (no.getState() == 1) {
+            oldState = "在用";
             User usering = userMapper.selectById(no.getUserId());
-            oldState = oldState+(usering.getName()+"/"+usering.getPhone());
+            oldState = oldState + (usering.getName() + "/" + usering.getPhone());
         }
-        if(goodsNo.getState()==0){
-            nowState="未用";
-        }else if(goodsNo.getState()==1){
-            nowState="在用";
+        if (goodsNo.getState() == 0) {
+            nowState = "未用";
+        } else if (goodsNo.getState() == 1) {
+            nowState = "在用";
             User usering = userMapper.selectById(goodsNo.getUserId());
-            nowState = nowState+(usering.getName()+"/"+usering.getPhone());
-        }else if(goodsNo.getState()==3){
-            nowState="报废";
+            nowState = nowState + (usering.getName() + "/" + usering.getPhone());
+        } else if (goodsNo.getState() == 3) {
+            nowState = "报废";
         }
-        String content = Constant.HANDLE_CONTENT.replace("oldState",oldState).replace("newState",nowState);
+        String content = Constant.HANDLE_CONTENT.replace("oldState", oldState).replace("newState", nowState);
         operateRecord.setContent(content);
         operateRecord.setGoodId(no.getGoodsId());
         operateRecord.setGoodNoId(no.getId());
@@ -173,7 +174,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
 
     @Override
     public HttpRespMsg operateList(Goods goods) {
-        HttpRespMsg msg= new HttpRespMsg();
+        HttpRespMsg msg = new HttpRespMsg();
         List<GoodsNoVO> list = operateRecordMapper.selectCondition(goods);
         msg.data = list;
         return msg;
@@ -184,17 +185,52 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
         HttpRespMsg msg = new HttpRespMsg();
         GoodsNo oldGoodsNo = goodsNoMapper.selectById(goodsNo.getId());
         GoodsNoVO vo = new GoodsNoVO();
-        BeanUtils.copyProperties(oldGoodsNo,vo);
+        BeanUtils.copyProperties(oldGoodsNo, vo);
         User user = userMapper.selectById(oldGoodsNo.getUserId());
-        if(user != null){
+        if (user != null) {
             vo.setUsername(user.getName());
         }
         msg.data = vo;
         return msg;
     }
 
+    @Override
+    public HttpRespMsg goodsNodel(GoodsNo goodsNo) {
+        HttpRespMsg msg = new HttpRespMsg();
+        GoodsNo oldGoodsNo = goodsNoMapper.selectById(goodsNo.getId());
+        if (oldGoodsNo.getState() != 0) {
+            msg.setError("当前编号的资产状态非空闲,不支持该操作。");
+            return msg;
+        }
+        goodsNoMapper.deleteById(goodsNo.getId());
+        return msg;
+    }
+
+    @Override
+    public HttpRespMsg goodsNoAdd(GoodsNo goodsNo,Integer count) {
+        HttpRespMsg msg = new HttpRespMsg();
+        GoodsNo oldGoodsNo = goodsNoMapper.selectOne(new QueryWrapper<GoodsNo>().eq("good_id", goodsNo.getGoodsId()).orderByDesc("id").last("limit 1"));
+        String prefix = oldGoodsNo.getModelNo().substring(0,oldGoodsNo.getModelNo().length()-4);
+        Integer start = Integer.parseInt(oldGoodsNo.getModelNo().substring(oldGoodsNo.getModelNo().length()-4));
+        List<GoodsNo> goodsNoList = new ArrayList<>();
+        for(int i=1;i<=count;i++){
+            String format = String.format("%04d", start+i);
+            BeanUtils.copyProperties(oldGoodsNo,goodsNo);
+            goodsNo.setModelNo(prefix+format);
+            goodsNo.setId(null);
+            goodsNoList.add(goodsNo);
+        }
+        if(!CollectionUtils.isEmpty(goodsNoList)){
+            goodsNoService.saveBatch(goodsNoList);
+        }
+        return msg;
+    }
+
     public static void main(String[] args) {
-        String format = String.format("%04d", 0);
-        System.out.println(format);
+//        String format = String.format("%04d", 0);
+//        System.out.println(format);
+        System.out.println("QWE-ASDF0001".substring(0,"QWE-ASDF0001".length()-4));
+        System.out.println("QWE-ASDF0001".substring("QWE-ASDF0001".length()-4));
+        System.out.println(Integer.parseInt("0001"));
     }
 }

+ 58 - 33
pcbms/src/main/resources/mapper/GoodsMapper.xml

@@ -4,18 +4,18 @@
 
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.hssx.pcbms.entity.Goods">
-        <id column="id" property="id" />
-        <result column="name" property="name" />
-        <result column="tag_id" property="tagId" />
-        <result column="model_number" property="modelNumber" />
-        <result column="unit" property="unit" />
-        <result column="address" property="address" />
-        <result column="factory" property="factory" />
-        <result column="pic" property="pic" />
-        <result column="service_life" property="serviceLife" />
-        <result column="next_indate" property="nextIndate" />
-        <result column="is_delete" property="isDelete" />
-        <result column="creator_id" property="creatorId" />
+        <id column="id" property="id"/>
+        <result column="name" property="name"/>
+        <result column="tag_id" property="tagId"/>
+        <result column="model_number" property="modelNumber"/>
+        <result column="unit" property="unit"/>
+        <result column="address" property="address"/>
+        <result column="factory" property="factory"/>
+        <result column="pic" property="pic"/>
+        <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>
 
     <!-- 通用查询结果列 -->
@@ -25,30 +25,54 @@
 
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMapVO" type="com.hssx.pcbms.entity.vo.GoodsVO">
-        <id column="id" property="id" />
-        <result column="name" property="name" />
-        <result column="tag_id" property="tagId" />
-        <result column="model_number" property="modelNumber" />
-        <result column="unit" property="unit" />
-        <result column="address" property="address" />
-        <result column="factory" property="factory" />
-        <result column="pic" property="pic" />
-        <result column="service_life" property="serviceLife" />
-        <result column="next_indate" property="nextIndate" />
-        <collection property="goodsNos" select="selectGoodsNoByGoodsId" javaType="java.util.List" column="{goodId = id}" ofType="com.hssx.pcbms.entity.GoodsNo">
+        <id column="id" property="id"/>
+        <result column="name" property="name"/>
+        <result column="tag_id" property="tagId"/>
+        <result column="model_number" property="modelNumber"/>
+        <result column="unit" property="unit"/>
+        <result column="address" property="address"/>
+        <result column="factory" property="factory"/>
+        <result column="pic" property="pic"/>
+        <result column="service_life" property="serviceLife"/>
+        <result column="next_indate" property="nextIndate"/>
+        <collection property="goodsNos" select="selectGoodsNoByGoodsId" javaType="java.util.List" column="{goodId = id}"
+                    ofType="com.hssx.pcbms.entity.GoodsNo">
         </collection>
         <!--<collection property="goodsNos" ofType="com.hssx.pcbms.entity.GoodsNo">-->
-            <!--<id column="nid" property="id" />-->
-            <!--<result column="model_no" property="modelNo" />-->
-            <!--<result column="division_code" property="divisionCode" />-->
-            <!--<result column="suffix_code" property="suffixCode" />-->
-            <!--<result column="state" property="state" />-->
-            <!--<result column="indate" property="indate" />-->
-            <!--<result column="goods_id" property="goodsId" />-->
-            <!--<result column="user_id" property="userId" />-->
+        <!--<id column="nid" property="id" />-->
+        <!--<result column="model_no" property="modelNo" />-->
+        <!--<result column="division_code" property="divisionCode" />-->
+        <!--<result column="suffix_code" property="suffixCode" />-->
+        <!--<result column="state" property="state" />-->
+        <!--<result column="indate" property="indate" />-->
+        <!--<result column="goods_id" property="goodsId" />-->
+        <!--<result column="user_id" property="userId" />-->
         <!--</collection>-->
     </resultMap>
 
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMapDetail" type="com.hssx.pcbms.entity.vo.GoodsVO">
+        <id column="id" property="id"/>
+        <result column="name" property="name"/>
+        <result column="tag_id" property="tagId"/>
+        <result column="model_number" property="modelNumber"/>
+        <result column="unit" property="unit"/>
+        <result column="address" property="address"/>
+        <result column="factory" property="factory"/>
+        <result column="pic" property="pic"/>
+        <result column="service_life" property="serviceLife"/>
+        <result column="next_indate" property="nextIndate"/>
+        <collection property="goodsNos" ofType="com.hssx.pcbms.entity.GoodsNo">
+            <id column="nid" property="id"/>
+            <result column="model_no" property="modelNo"/>
+            <result column="division_code" property="divisionCode"/>
+            <result column="suffix_code" property="suffixCode"/>
+            <result column="state" property="state"/>
+            <result column="indate" property="indate"/>
+            <result column="goods_id" property="goodsId"/>
+            <result column="user_id" property="userId"/>
+        </collection>
+    </resultMap>
     <select id="getListBycondition" resultMap="BaseResultMapVO">
         select
         id, name, tag_id, model_number, unit, address, factory, pic, service_life, next_indate
@@ -72,9 +96,10 @@
         where
               goods_id = #{goodId}
     </select>
-    <select id="getDetail" resultMap="BaseResultMapVO">
+    <select id="getDetail" resultMap="BaseResultMapDetail">
         select
-        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,
+        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