22 changed files with 466 additions and 986 deletions
@ -0,0 +1,56 @@ |
|||
package org.nl.wms.basedata.master.materialbase.controller; |
|||
|
|||
|
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.common.TableDataInfo; |
|||
import org.nl.common.domain.query.PageQuery; |
|||
import org.nl.modules.logging.annotation.Log; |
|||
import org.nl.wms.basedata.master.materialbase.service.dao.Materialbase; |
|||
import org.nl.wms.basedata.master.materialbase.service.dto.MaterialbaseQuery; |
|||
import org.nl.wms.basedata.master.materialbase.service.MaterialbaseService; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
|
|||
/** |
|||
* @author zhouz |
|||
* @date 2021-12-07 |
|||
**/ |
|||
@RestController |
|||
@RequiredArgsConstructor |
|||
@RequestMapping("/api/Materialbase") |
|||
@Slf4j |
|||
public class MaterialbaseController { |
|||
|
|||
private final MaterialbaseService materialBaseService; |
|||
|
|||
@GetMapping |
|||
@Log("查询物料") |
|||
public ResponseEntity<Object> query(MaterialbaseQuery whereJson, PageQuery page) { |
|||
return new ResponseEntity<>(TableDataInfo.build(materialBaseService.queryAll(whereJson, page)), HttpStatus.OK); |
|||
} |
|||
|
|||
@PostMapping |
|||
@Log("新增物料") |
|||
public ResponseEntity<Object> create(@Validated @RequestBody Materialbase dto) { |
|||
materialBaseService.create(dto); |
|||
return new ResponseEntity<>(HttpStatus.CREATED); |
|||
} |
|||
|
|||
@PutMapping |
|||
@Log("修改物料") |
|||
public ResponseEntity<Object> update(@Validated @RequestBody Materialbase dto) { |
|||
materialBaseService.update(dto); |
|||
return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
|||
} |
|||
|
|||
@Log("删除物料") |
|||
@DeleteMapping |
|||
public ResponseEntity<Object> delete(@RequestBody Long[] ids) { |
|||
materialBaseService.deleteAll(ids); |
|||
return new ResponseEntity<>(HttpStatus.OK); |
|||
} |
|||
} |
@ -0,0 +1,46 @@ |
|||
package org.nl.wms.basedata.master.materialbase.service; |
|||
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.service.IService; |
|||
import org.nl.common.domain.query.PageQuery; |
|||
import org.nl.wms.basedata.master.materialbase.service.dao.Materialbase; |
|||
import org.nl.wms.basedata.master.materialbase.service.dto.MaterialbaseQuery; |
|||
|
|||
/** |
|||
* @author zhouz |
|||
* @description 服务接口 |
|||
* @date 2021-12-07 |
|||
**/ |
|||
public interface MaterialbaseService extends IService<Materialbase> { |
|||
|
|||
/** |
|||
* 查询数据分页 |
|||
* |
|||
* @param whereJson 条件 |
|||
* @param page 分页参数 |
|||
* @return Map<String, Object> |
|||
*/ |
|||
IPage<Materialbase> queryAll(MaterialbaseQuery whereJson, PageQuery page); |
|||
|
|||
/** |
|||
* 创建 |
|||
* |
|||
* @param dto / |
|||
*/ |
|||
void create(Materialbase dto); |
|||
|
|||
/** |
|||
* 编辑 |
|||
* |
|||
* @param dto / |
|||
*/ |
|||
void update(Materialbase dto); |
|||
|
|||
/** |
|||
* 多选删除 |
|||
* |
|||
* @param ids / |
|||
*/ |
|||
void deleteAll(Long[] ids); |
|||
|
|||
} |
@ -0,0 +1,51 @@ |
|||
package org.nl.wms.basedata.master.materialbase.service.dao; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @author: zds |
|||
* @date: 2024-09-27 |
|||
* @description: |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = false) |
|||
@TableName("md_me_materialbase") |
|||
public class Materialbase implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@TableId(value = "material_id", type = IdType.NONE) |
|||
private String material_id; |
|||
//物料编码
|
|||
private String material_code; |
|||
//物料名称
|
|||
private String material_name; |
|||
//基本计量单位
|
|||
private String base_unit_id; |
|||
//创建人
|
|||
private String create_id; |
|||
//创建人姓名
|
|||
private String create_name; |
|||
//创建时间
|
|||
private String create_time; |
|||
//修改人
|
|||
private String update_id; |
|||
//修改人姓名
|
|||
private String update_name; |
|||
//修改时间
|
|||
private String update_time; |
|||
//是否启用
|
|||
private String is_used; |
|||
//是否删除
|
|||
private String is_delete; |
|||
@TableField(exist = false) |
|||
private String unit_name; |
|||
|
|||
} |
@ -0,0 +1,67 @@ |
|||
package org.nl.wms.basedata.master.materialbase.service.dao; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @author: zds |
|||
* @date: 2024-09-27 |
|||
* @description: |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = false) |
|||
@TableName("md_me_materialbaseproc") |
|||
public class MaterialbaseProc implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@TableId(value = "id", type = IdType.NONE) |
|||
private String id; |
|||
//物料编码
|
|||
private String MATNR; |
|||
//物料名称
|
|||
private String MATNR01; |
|||
//基本计量单位
|
|||
private String ERSDA; |
|||
//创建人
|
|||
private String MATFI; |
|||
//创建人姓名
|
|||
private String MTART; |
|||
//创建时间
|
|||
private String MEINS; |
|||
//修改人
|
|||
private String MATKL; |
|||
//修改人姓名
|
|||
private String NTGEW; |
|||
//修改时间
|
|||
private String GROES; |
|||
//是否启用
|
|||
private String WERKS; |
|||
//是否删除
|
|||
private String DISPO; |
|||
|
|||
private String BESKZ; |
|||
|
|||
private String RGEKZ; |
|||
|
|||
private String PRGRP; |
|||
|
|||
private String ZRESERVE1; |
|||
|
|||
private String ZRESERVE2; |
|||
|
|||
private String ZRESERVE3; |
|||
|
|||
private String ZRESERVE4; |
|||
|
|||
private String ZRESERVE5; |
|||
|
|||
private String create_time; |
|||
|
|||
} |
@ -0,0 +1,19 @@ |
|||
package org.nl.wms.basedata.master.materialbase.service.dao.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import org.nl.wms.basedata.master.materialbase.service.dao.Materialbase; |
|||
import org.nl.wms.basedata.master.materialbase.service.dto.MaterialbaseQuery; |
|||
|
|||
/** |
|||
* @author: zds |
|||
* @date: 2024-09-27 |
|||
* @description: |
|||
*/ |
|||
public interface MaterialbaseMapper extends BaseMapper<Materialbase> { |
|||
/** |
|||
* 分页查找 |
|||
* @return |
|||
*/ |
|||
IPage<Materialbase> queryMaterialbase(IPage<Materialbase> pages, MaterialbaseQuery query); |
|||
} |
@ -0,0 +1,22 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="org.nl.wms.basedata.master.materialbase.service.dao.mapper.MaterialbaseMapper"> |
|||
|
|||
<select id="queryMaterialbase" resultType="org.nl.wms.basedata.master.materialbase.service.dao.Materialbase"> |
|||
SELECT |
|||
mater.*, |
|||
unit.unit_name |
|||
FROM |
|||
md_me_materialbase mater |
|||
LEFT JOIN md_pb_measureunit unit on unit.measure_unit_id = mater.base_unit_id |
|||
WHERE 1=1 |
|||
and mater.is_delete = '0' |
|||
<if test="query.search != null"> |
|||
and (mater.material_code like CONCAT('%', #{query.search}, '%') or mater.material_name like CONCAT('%', #{query.search}, '%')) |
|||
</if> |
|||
<if test="query.is_used != null"> |
|||
and mater.is_used = #{query.is_used} |
|||
</if> |
|||
ORDER BY mater.material_code |
|||
</select> |
|||
</mapper> |
@ -0,0 +1,18 @@ |
|||
package org.nl.wms.basedata.master.materialbase.service.dto; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @author: zds |
|||
* @date: 2024-09-27 |
|||
* @description: |
|||
*/ |
|||
@Data |
|||
public class MaterialbaseQuery implements Serializable { |
|||
//编码或名称
|
|||
private String search; |
|||
//是否启用
|
|||
private String is_used; |
|||
} |
@ -0,0 +1,115 @@ |
|||
package org.nl.wms.basedata.master.materialbase.service.impl; |
|||
|
|||
|
|||
import cn.hutool.core.date.DateUtil; |
|||
import cn.hutool.core.util.IdUtil; |
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import cn.hutool.core.util.StrUtil; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.common.domain.query.PageQuery; |
|||
import org.nl.common.utils.SecurityUtils; |
|||
import org.nl.modules.common.exception.BadRequestException; |
|||
import org.nl.wms.basedata.master.materialbase.service.dao.Materialbase; |
|||
import org.nl.wms.basedata.master.materialbase.service.dao.mapper.MaterialbaseMapper; |
|||
import org.nl.wms.basedata.master.materialbase.service.dto.MaterialbaseQuery; |
|||
import org.nl.wms.basedata.master.materialbase.service.MaterialbaseService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
/** |
|||
* @author zhouz |
|||
* @description 服务实现 |
|||
* @date 2021-12-07 |
|||
**/ |
|||
@Service |
|||
@Slf4j |
|||
public class MaterialbaseServiceImpl extends ServiceImpl<MaterialbaseMapper, Materialbase> implements MaterialbaseService { |
|||
|
|||
@Autowired |
|||
private MaterialbaseMapper materialbaseMapper; |
|||
|
|||
@Override |
|||
public IPage<Materialbase> queryAll(MaterialbaseQuery whereJson, PageQuery pageQuery) { |
|||
String search = whereJson.getSearch(); |
|||
|
|||
if (!StrUtil.isEmpty(search)) { |
|||
//处理转义字符
|
|||
if (search.contains("\\")) { |
|||
search = search.replace("\\", "\\\\\\"); |
|||
} |
|||
} |
|||
whereJson.setSearch(search); |
|||
IPage<Materialbase> pages = new Page<>(pageQuery.getPage() + 1, pageQuery.getSize()); |
|||
pages = materialbaseMapper.queryMaterialbase(pages, whereJson); |
|||
return pages; |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void create(Materialbase dto) { |
|||
LambdaQueryWrapper<Materialbase> lam = new LambdaQueryWrapper<Materialbase>(); |
|||
lam.eq(Materialbase::getMaterial_code,dto.getMaterial_code()); |
|||
lam.eq(Materialbase::getIs_delete,"0"); |
|||
Materialbase materialbase = materialbaseMapper.selectOne(lam); |
|||
if (ObjectUtil.isNotEmpty(materialbase)) { |
|||
throw new BadRequestException("已存在相同的物料编号!"); |
|||
} |
|||
|
|||
String currentUserId = SecurityUtils.getCurrentUserId(); |
|||
String nickName = SecurityUtils.getCurrentNickName(); |
|||
String now = DateUtil.now(); |
|||
|
|||
dto.setMaterial_id(IdUtil.getSnowflake(1, 1).nextId()+""); |
|||
dto.setCreate_id(currentUserId); |
|||
dto.setCreate_name(nickName); |
|||
dto.setCreate_time(now); |
|||
materialbaseMapper.insert(dto); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(Materialbase dto) { |
|||
|
|||
LambdaQueryWrapper<Materialbase> lam = new LambdaQueryWrapper<Materialbase>(); |
|||
lam.eq(Materialbase::getMaterial_code,dto.getMaterial_code()); |
|||
lam.eq(Materialbase::getIs_delete,"0"); |
|||
lam.ne(Materialbase::getMaterial_id,dto.getMaterial_id()); |
|||
Materialbase materialbase = materialbaseMapper.selectOne(lam); |
|||
if (ObjectUtil.isNotEmpty(materialbase)) { |
|||
throw new BadRequestException("已存在相同的物料编号!"); |
|||
} |
|||
|
|||
String currentUserId = SecurityUtils.getCurrentUserId(); |
|||
String nickName = SecurityUtils.getCurrentNickName(); |
|||
String now = DateUtil.now(); |
|||
|
|||
dto.setUpdate_time(now); |
|||
dto.setUpdate_id(currentUserId); |
|||
dto.setUpdate_name(nickName); |
|||
materialbaseMapper.updateById(dto); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void deleteAll(Long[] ids) { |
|||
String currentUserId = SecurityUtils.getCurrentUserId(); |
|||
String nickName = SecurityUtils.getCurrentNickName(); |
|||
String now = DateUtil.now(); |
|||
//设置更新条件
|
|||
LambdaUpdateWrapper<Materialbase> lam = new LambdaUpdateWrapper<Materialbase>(); |
|||
lam.in(Materialbase::getMaterial_id,ids); |
|||
|
|||
lam.set(Materialbase::getIs_delete, "1"); |
|||
lam.set(Materialbase::getUpdate_id, currentUserId); |
|||
lam.set(Materialbase::getUpdate_name, nickName); |
|||
lam.set(Materialbase::getUpdate_time, now); |
|||
materialbaseMapper.update(null,lam); |
|||
} |
|||
|
|||
} |
@ -1,91 +0,0 @@ |
|||
package org.nl.wms.basedata.master.rest; |
|||
|
|||
|
|||
import cn.hutool.core.map.MapUtil; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.modules.logging.annotation.Log; |
|||
import org.nl.wms.basedata.master.constant.MaterOptTypeEnum; |
|||
import org.nl.wms.basedata.master.service.MaterialbaseService; |
|||
import org.nl.wms.basedata.master.service.dto.MaterialbaseDto; |
|||
import org.springframework.data.domain.Pageable; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @author zhouz |
|||
* @date 2021-12-07 |
|||
**/ |
|||
@RestController |
|||
@RequiredArgsConstructor |
|||
@RequestMapping("/api/Materialbase") |
|||
@Slf4j |
|||
public class MaterialbaseController { |
|||
|
|||
private final MaterialbaseService materialBaseService; |
|||
|
|||
@GetMapping |
|||
@Log("查询物料") |
|||
|
|||
//@PreAuthorize("@el.check('Materialbase:list')")
|
|||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) { |
|||
return new ResponseEntity<>(materialBaseService.queryAll(whereJson, page), HttpStatus.OK); |
|||
} |
|||
|
|||
@PostMapping |
|||
@Log("新增物料") |
|||
|
|||
//@PreAuthorize("@el.check('Materialbase:add')")
|
|||
public ResponseEntity<Object> create(@Validated @RequestBody MaterialbaseDto dto) { |
|||
materialBaseService.create(dto); |
|||
return new ResponseEntity<>(HttpStatus.CREATED); |
|||
} |
|||
|
|||
@PutMapping |
|||
@Log("修改物料") |
|||
|
|||
//@PreAuthorize("@el.check('Materialbase:edit')")
|
|||
public ResponseEntity<Object> update(@Validated @RequestBody MaterialbaseDto dto) { |
|||
materialBaseService.update(dto); |
|||
return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
|||
} |
|||
|
|||
@Log("删除物料") |
|||
|
|||
//@PreAuthorize("@el.check('Materialbase:del')")
|
|||
@DeleteMapping |
|||
public ResponseEntity<Object> delete(@RequestBody Long[] ids) { |
|||
materialBaseService.deleteAll(ids); |
|||
return new ResponseEntity<>(HttpStatus.OK); |
|||
} |
|||
|
|||
|
|||
@Log("判断物料操作类型") |
|||
|
|||
@PostMapping("/isAlongMaterType") |
|||
public ResponseEntity<Object> isAlongMaterType(@RequestBody Map map) { |
|||
String materOpt_code = MapUtil.getStr(map, "materOpt_code"); |
|||
String material_id = MapUtil.getStr(map, "material_id"); |
|||
String material_type_id = MapUtil.getStr(map, "material_type_id"); |
|||
return new ResponseEntity<>(materialBaseService.isAlongMaterType(materOpt_code, material_id, material_type_id), HttpStatus.OK); |
|||
} |
|||
|
|||
@Log("查询物料操作类型") |
|||
|
|||
@PostMapping("/getMaterOptType") |
|||
public ResponseEntity<Object> getMaterOptType(@RequestBody Map map) { |
|||
String materOpt_code = MapUtil.getStr(map, "materOpt_code"); |
|||
return new ResponseEntity<>(MaterOptTypeEnum.getObj(materOpt_code), HttpStatus.OK); |
|||
} |
|||
|
|||
@Log("查询产品系列类型") |
|||
|
|||
@GetMapping("/getProductSeries") |
|||
public ResponseEntity<Object> getProductSeries() { |
|||
return new ResponseEntity<>(materialBaseService.getProductSeries("1527572574832300032"), HttpStatus.OK); |
|||
} |
|||
} |
@ -1,94 +0,0 @@ |
|||
package org.nl.wms.basedata.master.service; |
|||
|
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import org.nl.wms.basedata.master.service.dto.MaterialbaseDto; |
|||
import org.springframework.data.domain.Pageable; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @author zhouz |
|||
* @description 服务接口 |
|||
* @date 2021-12-07 |
|||
**/ |
|||
public interface MaterialbaseService { |
|||
|
|||
/** |
|||
* 查询数据分页 |
|||
* |
|||
* @param whereJson 条件 |
|||
* @param page 分页参数 |
|||
* @return Map<String, Object> |
|||
*/ |
|||
Map<String, Object> queryAll(Map whereJson, Pageable page); |
|||
|
|||
/** |
|||
* 查询所有数据不分页 |
|||
* |
|||
* @param whereJson 条件参数 |
|||
* @return List<MaterialbaseDto> |
|||
*/ |
|||
List<MaterialbaseDto> queryAll(Map whereJson); |
|||
|
|||
/** |
|||
* 根据ID查询 |
|||
* |
|||
* @param material_id ID |
|||
* @return Materialbase |
|||
*/ |
|||
MaterialbaseDto findById(Long material_id); |
|||
|
|||
/** |
|||
* 根据编码查询 |
|||
* |
|||
* @param code code |
|||
* @return Materialbase |
|||
*/ |
|||
MaterialbaseDto findByCode(String code); |
|||
|
|||
|
|||
/** |
|||
* 创建 |
|||
* |
|||
* @param dto / |
|||
*/ |
|||
void create(MaterialbaseDto dto); |
|||
|
|||
/** |
|||
* 编辑 |
|||
* |
|||
* @param dto / |
|||
*/ |
|||
void update(MaterialbaseDto dto); |
|||
|
|||
/** |
|||
* 多选删除 |
|||
* |
|||
* @param ids / |
|||
*/ |
|||
void deleteAll(Long[] ids); |
|||
|
|||
/** |
|||
* 根据物料标识或类型判断物料类型:对应MaterOptTypeEnum类定义的类型 |
|||
* |
|||
* @param material_id |
|||
* @param material_type_id |
|||
* @param materOpt_code |
|||
* @return |
|||
*/ |
|||
boolean isAlongMaterType(String materOpt_code, String material_id, String material_type_id); |
|||
|
|||
/** |
|||
* 根据编码获取物料操作类型 |
|||
* |
|||
* @param materOpt_code MaterOptTypeEnum |
|||
* @return |
|||
*/ |
|||
JSONObject getMaterOptType(String materOpt_code); |
|||
|
|||
JSONArray getProductSeries(String parent_class_id); |
|||
|
|||
|
|||
} |
@ -1,105 +0,0 @@ |
|||
package org.nl.wms.basedata.master.service.dto; |
|||
|
|||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
|||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* @author zhouz |
|||
* @description / |
|||
* @date 2021-12-07 |
|||
**/ |
|||
@Data |
|||
public class MaterialbaseDto implements Serializable { |
|||
|
|||
/** |
|||
* 防止精度丢失 |
|||
*/ |
|||
@JsonSerialize(using = ToStringSerializer.class) |
|||
private Long material_id; |
|||
|
|||
/** |
|||
* 物料编码 |
|||
*/ |
|||
private String material_code; |
|||
|
|||
/** |
|||
* 物料名称 |
|||
*/ |
|||
private String material_name; |
|||
|
|||
private String material_spec; |
|||
|
|||
private String material_model; |
|||
|
|||
private String english_name; |
|||
|
|||
private long base_unit_id; |
|||
|
|||
private long assist_unit_id; |
|||
private String base_unit_name; |
|||
|
|||
private String approve_fileno; |
|||
|
|||
private String print_no; |
|||
|
|||
/** |
|||
* 物料分类 |
|||
*/ |
|||
private Long material_type_id; |
|||
|
|||
private Long len_unit_id; |
|||
|
|||
private BigDecimal length; |
|||
|
|||
private BigDecimal width; |
|||
|
|||
private BigDecimal height; |
|||
|
|||
/** |
|||
* 计量单位 |
|||
*/ |
|||
private Long weight_unit_id; |
|||
|
|||
private BigDecimal gross_weight; |
|||
|
|||
private BigDecimal net_weight; |
|||
|
|||
private Long cubage_unit_id; |
|||
|
|||
private BigDecimal cubage; |
|||
|
|||
private String create_id; |
|||
|
|||
private String create_name; |
|||
|
|||
private String create_time; |
|||
|
|||
private String update_optid; |
|||
|
|||
private String update_optname; |
|||
|
|||
private String update_time; |
|||
|
|||
private String is_used_time; |
|||
|
|||
/** |
|||
* 是否启用 |
|||
*/ |
|||
private String is_used; |
|||
|
|||
private String is_delete; |
|||
|
|||
private String ext_id; |
|||
|
|||
private String material_height_type; |
|||
|
|||
private Long ass_unit_id; |
|||
|
|||
private Long product_series; |
|||
|
|||
private Integer standing_time; |
|||
} |
@ -1,242 +0,0 @@ |
|||
package org.nl.wms.basedata.master.service.impl; |
|||
|
|||
|
|||
import cn.hutool.core.date.DateUtil; |
|||
import cn.hutool.core.map.MapUtil; |
|||
import cn.hutool.core.util.IdUtil; |
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import cn.hutool.core.util.StrUtil; |
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.common.utils.SecurityUtils; |
|||
import org.nl.modules.common.exception.BadRequestException; |
|||
import org.nl.modules.wql.WQL; |
|||
import org.nl.modules.wql.core.bean.WQLObject; |
|||
import org.nl.modules.wql.util.WqlUtil; |
|||
import org.nl.wms.basedata.master.constant.MaterOptTypeEnum; |
|||
import org.nl.wms.basedata.master.service.ClassstandardService; |
|||
import org.nl.wms.basedata.master.service.MaterialbaseService; |
|||
import org.nl.wms.basedata.master.service.dto.MaterialbaseDto; |
|||
import org.springframework.data.domain.Pageable; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Set; |
|||
|
|||
/** |
|||
* @author zhouz |
|||
* @description 服务实现 |
|||
* @date 2021-12-07 |
|||
**/ |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
@Slf4j |
|||
public class MaterialbaseServiceImpl implements MaterialbaseService { |
|||
private final ClassstandardService classstandardService; |
|||
|
|||
@Override |
|||
public Map<String, Object> queryAll(Map whereJson, Pageable page) { |
|||
String search = MapUtil.getStr(whereJson, "search"); |
|||
//只查询木箱
|
|||
String box = MapUtil.getStr(whereJson, "box"); |
|||
//物料限制的时候使用,初始化页面
|
|||
String class_idStr = MapUtil.getStr(whereJson, "class_idStr"); |
|||
String material_type_id = MapUtil.getStr(whereJson, "material_type_id"); |
|||
String class_code = MapUtil.getStr(whereJson, "class_code"); |
|||
String ids = MapUtil.getStr(whereJson, "ids"); |
|||
|
|||
|
|||
HashMap<String, String> map = new HashMap<>(); |
|||
map.put("flag", "1"); |
|||
|
|||
if (!StrUtil.isEmpty(search)) { |
|||
//处理转义字符
|
|||
if (search.contains("\\")) { |
|||
search = search.replace("\\", "\\\\\\"); |
|||
} |
|||
map.put("search", "%" + search + "%"); |
|||
} |
|||
if (!StrUtil.isEmpty(box)) { |
|||
//处理转义字符
|
|||
if (box.contains("\\")) { |
|||
box = box.replace("\\", "\\\\\\"); |
|||
} |
|||
map.put("box", "%" + box + "%"); |
|||
} |
|||
|
|||
//处理物料当前节点的所有子节点
|
|||
if (!StrUtil.isEmpty(material_type_id)) { |
|||
map.put("material_type_id", material_type_id); |
|||
String classIds = classstandardService.getChildIdStr(material_type_id); |
|||
map.put("classIds", classIds); |
|||
} else if (ObjectUtil.isNotEmpty(class_idStr)) { |
|||
String classIds = classstandardService.getAllChildIdStr(class_idStr); |
|||
map.put("classIds", classIds); |
|||
} |
|||
|
|||
if (!StrUtil.isEmpty(class_code)) { |
|||
map.put("class_code", class_code + "%"); |
|||
} |
|||
|
|||
StringBuffer where = new StringBuffer(); |
|||
if (StrUtil.isNotEmpty(ids)) { |
|||
ids = ids.replaceAll("\'", ""); |
|||
String[] strs = ids.split(","); |
|||
where.append("("); |
|||
for (int i = 0; i < strs.length; ) { |
|||
where.append("class.class_code like '" + strs[i] + "%'"); |
|||
i++; |
|||
if (i < strs.length) { |
|||
where.append(" or "); |
|||
} |
|||
} |
|||
where.append(")"); |
|||
map.put("idssql", where.toString()); |
|||
} else { |
|||
map.put("idssql", "1=1"); |
|||
} |
|||
|
|||
JSONObject jo = WQL.getWO("QMD_ME_MATERIAL").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "material_id"); |
|||
return jo; |
|||
} |
|||
|
|||
@Override |
|||
public List<MaterialbaseDto> queryAll(Map whereJson) { |
|||
WQLObject wo = WQLObject.getWQLObject("md_me_materialbase"); |
|||
JSONArray arr = wo.query().getResultJSONArray(0); |
|||
List<MaterialbaseDto> list = arr.toJavaList(MaterialbaseDto.class); |
|||
return list; |
|||
} |
|||
|
|||
@Override |
|||
public MaterialbaseDto findById(Long material_id) { |
|||
WQLObject wo = WQLObject.getWQLObject("md_me_materialbase"); |
|||
JSONObject json = wo.query("material_id =" + material_id + "").uniqueResult(0); |
|||
String unit_name = WQLObject.getWQLObject("md_pb_measureunit").query("measure_unit_id= '" + json.getString("base_unit_id") + "'").uniqueResult(0).getString("unit_name"); |
|||
json.put("base_unit_name", unit_name); |
|||
final MaterialbaseDto obj = json.toJavaObject(MaterialbaseDto.class); |
|||
return obj; |
|||
} |
|||
|
|||
@Override |
|||
public MaterialbaseDto findByCode(String code) { |
|||
WQLObject wo = WQLObject.getWQLObject("md_me_materialbase"); |
|||
if (StrUtil.isNotEmpty(code) && code.contains("\\")) { |
|||
code = code.replace("\\", "\\\\"); |
|||
} |
|||
JSONObject json = wo.query("material_code ='" + code + "'").uniqueResult(0); |
|||
if (ObjectUtil.isEmpty(json)) { |
|||
return null; |
|||
} |
|||
String unit_name = WQLObject.getWQLObject("md_pb_measureunit").query("measure_unit_id= '" + json.getString("base_unit_id") + "'").uniqueResult(0).getString("unit_name"); |
|||
json.put("base_unit_name", unit_name); |
|||
final MaterialbaseDto obj = json.toJavaObject(MaterialbaseDto.class); |
|||
return obj; |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void create(MaterialbaseDto dto) { |
|||
String currentUserId = SecurityUtils.getCurrentUserId(); |
|||
String nickName = SecurityUtils.getCurrentNickName(); |
|||
String now = DateUtil.now(); |
|||
|
|||
dto.setMaterial_id(IdUtil.getSnowflake(1, 1).nextId()); |
|||
dto.setCreate_id(currentUserId); |
|||
dto.setCreate_name(nickName); |
|||
dto.setUpdate_optid(currentUserId); |
|||
dto.setUpdate_optname(nickName); |
|||
dto.setUpdate_time(now); |
|||
dto.setCreate_time(now); |
|||
WQLObject wo = WQLObject.getWQLObject("md_me_materialbase"); |
|||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto)); |
|||
wo.insert(json); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(MaterialbaseDto dto) { |
|||
MaterialbaseDto entity = this.findById(dto.getMaterial_id()); |
|||
if (entity == null) { |
|||
throw new BadRequestException("被删除或无权限,操作失败!"); |
|||
} |
|||
|
|||
String currentUserId = SecurityUtils.getCurrentUserId(); |
|||
String nickName = SecurityUtils.getCurrentNickName(); |
|||
|
|||
String now = DateUtil.now(); |
|||
dto.setUpdate_time(now); |
|||
dto.setUpdate_optid(currentUserId); |
|||
dto.setUpdate_optname(nickName); |
|||
WQLObject wo = WQLObject.getWQLObject("md_me_materialbase"); |
|||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto)); |
|||
wo.update(json); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void deleteAll(Long[] ids) { |
|||
String currentUserId = SecurityUtils.getCurrentUserId(); |
|||
String nickName = SecurityUtils.getCurrentNickName(); |
|||
String now = DateUtil.now(); |
|||
|
|||
WQLObject wo = WQLObject.getWQLObject("md_me_materialbase"); |
|||
for (Long material_id : ids) { |
|||
JSONObject param = new JSONObject(); |
|||
param.put("material_id", String.valueOf(material_id)); |
|||
param.put("is_delete", "1"); |
|||
param.put("update_optid", currentUserId); |
|||
param.put("update_optname", nickName); |
|||
param.put("update_time", now); |
|||
wo.update(param); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public boolean isAlongMaterType(String materOpt_code, String material_id, String material_type_id) { |
|||
if (ObjectUtil.isNotEmpty(material_id)) { |
|||
Long long_mater = Long.parseLong(material_id); |
|||
material_type_id = this.findById(long_mater).getMaterial_type_id() + ""; |
|||
} |
|||
if (ObjectUtil.isEmpty(material_type_id)) { |
|||
throw new BadRequestException("物料类型不能为空!"); |
|||
} |
|||
String class_idStr = MaterOptTypeEnum.getObj(materOpt_code).getString("class_idStr"); |
|||
|
|||
Set<String> set = classstandardService.getAllChildIdSet(class_idStr); |
|||
if (ObjectUtil.isNotEmpty(set)) { |
|||
return set.contains(material_type_id); |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
@Override |
|||
public JSONObject getMaterOptType(String materOpt_code) { |
|||
return MaterOptTypeEnum.getObj(materOpt_code); |
|||
} |
|||
|
|||
@Override |
|||
public JSONArray getProductSeries(String parent_class_id) { |
|||
WQLObject wo = WQLObject.getWQLObject("MD_PB_ClassStandard"); |
|||
JSONArray parentArray = wo.query("is_delete = '0' and parent_class_id = '" + parent_class_id + "'").getResultJSONArray(0); |
|||
JSONArray newParentArray = new JSONArray(); |
|||
for (int i = 0; i < parentArray.size(); i++) { |
|||
JSONObject parentMap = parentArray.getJSONObject(i); |
|||
JSONObject newParentMap = new JSONObject(); |
|||
JSONArray children = this.getProductSeries(parentMap.getString("class_id")); |
|||
newParentMap.put("children", children); |
|||
newParentMap.put("label", parentMap.getString("class_name")); |
|||
newParentMap.put("id", parentMap.getString("class_id")); |
|||
newParentArray.add(newParentMap); |
|||
} |
|||
return newParentArray; |
|||
} |
|||
|
|||
} |
@ -1,73 +0,0 @@ |
|||
[交易说明] |
|||
交易名: 物料分页查询 |
|||
所属模块: |
|||
功能简述: |
|||
版权所有: |
|||
表引用: |
|||
版本经历: |
|||
|
|||
[数据库] |
|||
--指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 |
|||
|
|||
[IO定义] |
|||
################################################# |
|||
## 表字段对应输入参数 |
|||
################################################# |
|||
输入.flag TYPEAS s_string |
|||
输入.search TYPEAS s_string |
|||
输入.box TYPEAS s_string |
|||
输入.class_code TYPEAS s_string |
|||
输入.idssql TYPEAS f_string |
|||
输入.classIds TYPEAS f_string |
|||
|
|||
[临时表] |
|||
--这边列出来的临时表就会在运行期动态创建 |
|||
|
|||
[临时变量] |
|||
--所有中间过程变量均可在此处定义 |
|||
|
|||
[业务过程] |
|||
|
|||
########################################## |
|||
# 1、输入输出检查 # |
|||
########################################## |
|||
|
|||
|
|||
########################################## |
|||
# 2、主过程前处理 # |
|||
########################################## |
|||
|
|||
|
|||
########################################## |
|||
# 3、业务主过程 # |
|||
########################################## |
|||
|
|||
IF 输入.flag = "1" |
|||
PAGEQUERY |
|||
SELECT |
|||
mb.*, |
|||
unit_name, |
|||
unit_name as base_unit_id_name |
|||
FROM |
|||
md_me_materialbase mb |
|||
LEFT JOIN md_pb_measureunit unit ON unit.measure_unit_id = mb.base_unit_id |
|||
WHERE |
|||
mb.is_delete = '0' |
|||
OPTION 输入.search <> "" |
|||
( |
|||
mb.material_code like 输入.search |
|||
OR |
|||
mb.material_name like 输入.search |
|||
) |
|||
ENDOPTION |
|||
OPTION 输入.box <> "" |
|||
( |
|||
mb.material_name like 输入.box |
|||
) |
|||
ENDOPTION |
|||
ENDSELECT |
|||
ENDPAGEQUERY |
|||
ENDIF |
|||
|
|||
|
|||
|
Loading…
Reference in new issue