|
@@ -23,6 +23,7 @@ import com.hssx.pcbms.util.UploadFileToFileNameUtil;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
@@ -97,9 +98,9 @@ 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) {
|
|
- System.out.println("页数:"+page.getPageNum());
|
|
|
|
|
|
+ System.out.println("页数:" + page.getPageNum());
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
- PageHelper.startPage(page.getPageNum(),page.getPageSize());
|
|
|
|
|
|
+ PageHelper.startPage(page.getPageNum(), page.getPageSize());
|
|
List<GoodsVO> list = goodsMapper.getListBycondition(keyName, tagId);
|
|
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;
|
|
@@ -135,7 +136,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public HttpRespMsg handle(GoodsNo goodsNo,Integer currentUserId) {
|
|
|
|
|
|
+ public HttpRespMsg handle(GoodsNo goodsNo, Integer currentUserId) {
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
User user = userMapper.selectById(currentUserId);
|
|
User user = userMapper.selectById(currentUserId);
|
|
GoodsNo no = goodsNoMapper.selectById(goodsNo.getId());
|
|
GoodsNo no = goodsNoMapper.selectById(goodsNo.getId());
|
|
@@ -144,23 +145,23 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
OperateRecord operateRecord = new OperateRecord();
|
|
OperateRecord operateRecord = new OperateRecord();
|
|
String oldState = "";
|
|
String oldState = "";
|
|
String nowState = "";
|
|
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());
|
|
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());
|
|
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.setContent(content);
|
|
operateRecord.setGoodId(no.getGoodsId());
|
|
operateRecord.setGoodId(no.getGoodsId());
|
|
operateRecord.setGoodNoId(no.getId());
|
|
operateRecord.setGoodNoId(no.getId());
|
|
@@ -173,7 +174,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public HttpRespMsg operateList(Goods goods) {
|
|
public HttpRespMsg operateList(Goods goods) {
|
|
- HttpRespMsg msg= new HttpRespMsg();
|
|
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
List<GoodsNoVO> list = operateRecordMapper.selectCondition(goods);
|
|
List<GoodsNoVO> list = operateRecordMapper.selectCondition(goods);
|
|
msg.data = list;
|
|
msg.data = list;
|
|
return msg;
|
|
return msg;
|
|
@@ -184,17 +185,52 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
GoodsNo oldGoodsNo = goodsNoMapper.selectById(goodsNo.getId());
|
|
GoodsNo oldGoodsNo = goodsNoMapper.selectById(goodsNo.getId());
|
|
GoodsNoVO vo = new GoodsNoVO();
|
|
GoodsNoVO vo = new GoodsNoVO();
|
|
- BeanUtils.copyProperties(oldGoodsNo,vo);
|
|
|
|
|
|
+ BeanUtils.copyProperties(oldGoodsNo, vo);
|
|
User user = userMapper.selectById(oldGoodsNo.getUserId());
|
|
User user = userMapper.selectById(oldGoodsNo.getUserId());
|
|
- if(user != null){
|
|
|
|
|
|
+ if (user != null) {
|
|
vo.setUsername(user.getName());
|
|
vo.setUsername(user.getName());
|
|
}
|
|
}
|
|
msg.data = vo;
|
|
msg.data = vo;
|
|
return msg;
|
|
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) {
|
|
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"));
|
|
}
|
|
}
|
|
}
|
|
}
|