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