|
@@ -0,0 +1,128 @@
|
|
|
+/*
|
|
|
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
|
|
+ *
|
|
|
+ * Redistribution and use in source and binary forms, with or without
|
|
|
+ * modification, are permitted provided that the following conditions are met:
|
|
|
+ *
|
|
|
+ * Redistributions of source code must retain the above copyright notice,
|
|
|
+ * this list of conditions and the following disclaimer.
|
|
|
+ * Redistributions in binary form must reproduce the above copyright
|
|
|
+ * notice, this list of conditions and the following disclaimer in the
|
|
|
+ * documentation and/or other materials provided with the distribution.
|
|
|
+ * Neither the name of the dreamlu.net developer nor the names of its
|
|
|
+ * contributors may be used to endorse or promote products derived from
|
|
|
+ * this software without specific prior written permission.
|
|
|
+ * Author: Chill 庄骞 (smallchill@163.com)
|
|
|
+ */
|
|
|
+package com.fjhx.material.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.fjhx.material.entity.Material;
|
|
|
+import com.fjhx.material.entity.MaterialExtend;
|
|
|
+import com.fjhx.material.mapper.MaterialMapper;
|
|
|
+import com.fjhx.material.service.IMaterialExtendService;
|
|
|
+import com.fjhx.material.service.IMaterialService;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springblade.core.log.exception.ServiceException;
|
|
|
+import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
+import org.springblade.core.tool.utils.StringUtil;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 物料 服务实现类
|
|
|
+ *
|
|
|
+ * @author BladeX
|
|
|
+ * @since 2022-07-21
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> implements IMaterialService {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IMaterialExtendService materialExtendService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增接口
|
|
|
+ * @param material
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void addMaterial(Material material) {
|
|
|
+ if(StringUtil.isEmpty(material.getCategoryId())||
|
|
|
+ StringUtil.isEmpty(material.getCode())||
|
|
|
+ StringUtil.isEmpty(material.getName())){
|
|
|
+ throw new ServiceException("参数异常");
|
|
|
+ }
|
|
|
+ material.setCreate();
|
|
|
+ save(material);
|
|
|
+ if(ObjectUtil.isNotEmpty(material.getWidth())||
|
|
|
+ ObjectUtil.isNotEmpty(material.getUnitWeight())){
|
|
|
+ //添加扩展表
|
|
|
+ MaterialExtend extend = new MaterialExtend();
|
|
|
+ extend.setUnitWeight(material.getUnitWeight());
|
|
|
+ extend.setWidth(material.getWidth());
|
|
|
+ extend.setMaterialId(material.getId());
|
|
|
+ materialExtendService.save(extend);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改
|
|
|
+ * @param material
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void editMaterial(Material material) {
|
|
|
+ if(StringUtils.isEmpty(material.getId())){
|
|
|
+ throw new ServiceException("参数异常");
|
|
|
+ }
|
|
|
+ //扩展表不能修改
|
|
|
+// if(ObjectUtil.isNotEmpty(material.getWidth())||
|
|
|
+// ObjectUtil.isNotEmpty(material.getUnitWeight())){
|
|
|
+// //修改数据
|
|
|
+// MaterialExtend extend = new MaterialExtend();
|
|
|
+// extend.setUnitWeight(material.getUnitWeight());
|
|
|
+// extend.setWidth(material.getWidth());
|
|
|
+// materialExtendService.update(extend,Wrappers.<MaterialExtend>query().lambda().eq(MaterialExtend::getMaterialId,material.getId()));
|
|
|
+// }
|
|
|
+ material.setUpdate();
|
|
|
+ updateById(material);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除
|
|
|
+ * @param id
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void delMaterial(String id) {
|
|
|
+ removeById(id);
|
|
|
+// materialExtendService.remove(Wrappers.<MaterialExtend>query().lambda().eq(MaterialExtend::getMaterialId,id));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 列表
|
|
|
+ * @param condition
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<Material> getList(Map<String, Object> condition) {
|
|
|
+ return baseMapper.getList(condition);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 列表条数
|
|
|
+ * @param condition
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Integer getListCount(Map<String, Object> condition) {
|
|
|
+ return baseMapper.getListCount(condition);
|
|
|
+ }
|
|
|
+}
|