入库盘点
This commit is contained in:
parent
2dcbb2a6d3
commit
4b39107750
|
|
@ -8,6 +8,7 @@ import com.bonus.sgzb.material.domain.SavePutInfoDto;
|
||||||
import com.bonus.sgzb.material.service.InventoryAndWarehousingService;
|
import com.bonus.sgzb.material.service.InventoryAndWarehousingService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
@ -21,6 +22,7 @@ import java.util.List;
|
||||||
@Api(tags = " 入库盘点")
|
@Api(tags = " 入库盘点")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/inventoryAndWarehousing")
|
@RequestMapping("/inventoryAndWarehousing")
|
||||||
|
@Slf4j
|
||||||
public class InventoryAndWarehousingController extends BaseController {
|
public class InventoryAndWarehousingController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private InventoryAndWarehousingService inventoryAndWarehousingService;
|
private InventoryAndWarehousingService inventoryAndWarehousingService;
|
||||||
|
|
@ -31,6 +33,7 @@ public class InventoryAndWarehousingController extends BaseController {
|
||||||
@ApiOperation(value = "获取入库盘点列表")
|
@ApiOperation(value = "获取入库盘点列表")
|
||||||
@GetMapping("/getList")
|
@GetMapping("/getList")
|
||||||
public TableDataInfo getList(PutInStorageBean bean) {
|
public TableDataInfo getList(PutInStorageBean bean) {
|
||||||
|
log.info("获取入库盘点列表传参:{}", bean);
|
||||||
startPage();
|
startPage();
|
||||||
List<PutInStorageBean> list = inventoryAndWarehousingService.getList(bean);
|
List<PutInStorageBean> list = inventoryAndWarehousingService.getList(bean);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ public class MachIneDto {
|
||||||
* 创建者
|
* 创建者
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "创建者")
|
@ApiModelProperty(value = "创建者")
|
||||||
private String creator;
|
private Long creator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 入库形式
|
* 入库形式
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,10 @@ public class PutInStorageBean extends BaseEntity {
|
||||||
@ApiModelProperty(value = "入库形式")
|
@ApiModelProperty(value = "入库形式")
|
||||||
private String putInType;
|
private String putInType;
|
||||||
|
|
||||||
|
/** 关键字 */
|
||||||
|
@ApiModelProperty(value = "关键字")
|
||||||
|
private String keyWord;
|
||||||
|
|
||||||
/** 入库数量 */
|
/** 入库数量 */
|
||||||
@ApiModelProperty(value = "入库数量")
|
@ApiModelProperty(value = "入库数量")
|
||||||
private BigDecimal num;
|
private BigDecimal num;
|
||||||
|
|
@ -34,11 +38,11 @@ public class PutInStorageBean extends BaseEntity {
|
||||||
|
|
||||||
/** 入库人 */
|
/** 入库人 */
|
||||||
@ApiModelProperty(value = "入库人")
|
@ApiModelProperty(value = "入库人")
|
||||||
private String userName;
|
private String modelName;
|
||||||
|
|
||||||
/** 盘点入库单号 */
|
/** 盘点入库单号 */
|
||||||
@ApiModelProperty(value = "盘点入库单号")
|
@ApiModelProperty(value = "盘点入库单号")
|
||||||
private String code;
|
private String kindName;
|
||||||
|
|
||||||
/** 单位ID */
|
/** 单位ID */
|
||||||
@ApiModelProperty(value = "单位ID")
|
@ApiModelProperty(value = "单位ID")
|
||||||
|
|
@ -62,7 +66,7 @@ public class PutInStorageBean extends BaseEntity {
|
||||||
|
|
||||||
/** 备注 */
|
/** 备注 */
|
||||||
@ApiModelProperty(value = "备注")
|
@ApiModelProperty(value = "备注")
|
||||||
private String remarks;
|
private String remark;
|
||||||
|
|
||||||
|
|
||||||
/** 主信息 */
|
/** 主信息 */
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ public class SavePutInfoDto extends BaseEntity {
|
||||||
* 创建者
|
* 创建者
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "创建者")
|
@ApiModelProperty(value = "创建者")
|
||||||
private String creator;
|
private Long creator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import com.bonus.sgzb.material.domain.PutInStorageBean;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -72,4 +73,10 @@ public interface InventoryAndWarehousingMapper {
|
||||||
*/
|
*/
|
||||||
int selectByCode(String code);
|
int selectByCode(String code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询
|
||||||
|
* @param nowDate
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int selectTaskNumByMonth(@Param("date") Date nowDate);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.bonus.sgzb.material.service.impl;
|
package com.bonus.sgzb.material.service.impl;
|
||||||
|
|
||||||
|
import com.bonus.sgzb.common.core.utils.DateUtils;
|
||||||
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.sgzb.common.security.utils.SecurityUtils;
|
import com.bonus.sgzb.common.security.utils.SecurityUtils;
|
||||||
import com.bonus.sgzb.material.config.ExceptionEnum;
|
import com.bonus.sgzb.material.config.ExceptionEnum;
|
||||||
|
|
@ -8,13 +9,14 @@ import com.bonus.sgzb.material.domain.PutInStorageBean;
|
||||||
import com.bonus.sgzb.material.domain.SavePutInfoDto;
|
import com.bonus.sgzb.material.domain.SavePutInfoDto;
|
||||||
import com.bonus.sgzb.material.mapper.InventoryAndWarehousingMapper;
|
import com.bonus.sgzb.material.mapper.InventoryAndWarehousingMapper;
|
||||||
import com.bonus.sgzb.material.service.InventoryAndWarehousingService;
|
import com.bonus.sgzb.material.service.InventoryAndWarehousingService;
|
||||||
import com.bonus.sgzb.material.config.FieldGenerator;
|
import com.bonus.sgzb.material.vo.GlobalContants;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -39,6 +41,26 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi
|
||||||
return inventoryAndWarehousingMapper.getList(bean);
|
return inventoryAndWarehousingMapper.getList(bean);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成code编码
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String genderBackCode() {
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
|
||||||
|
Date nowDate = DateUtils.getNowDate();
|
||||||
|
String format = dateFormat.format(nowDate);
|
||||||
|
int taskNum = inventoryAndWarehousingMapper.selectTaskNumByMonth(nowDate) + 1;
|
||||||
|
String code = "";
|
||||||
|
if (taskNum > GlobalContants.NUM1 && taskNum < GlobalContants.NUM2) {
|
||||||
|
code = "PD" + format + "-00" + taskNum;
|
||||||
|
} else if (taskNum > GlobalContants.NUM3 && taskNum < GlobalContants.NUM4) {
|
||||||
|
code = "PD" + format + "-0" + taskNum;
|
||||||
|
} else {
|
||||||
|
code = "PD" + format + "-000" + taskNum;
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增入库盘点
|
* 新增入库盘点
|
||||||
* @param dto
|
* @param dto
|
||||||
|
|
@ -49,23 +71,14 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi
|
||||||
public AjaxResult savePutInfo(SavePutInfoDto dto) {
|
public AjaxResult savePutInfo(SavePutInfoDto dto) {
|
||||||
log.info("新增入库盘点入参dto:{}", dto);
|
log.info("新增入库盘点入参dto:{}", dto);
|
||||||
Long userId = SecurityUtils.getLoginUser().getUserid();
|
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||||
dto.setCreator(userId.toString());
|
dto.setCreator(userId);
|
||||||
List<String> codeList = new ArrayList<>();
|
String code = genderBackCode();
|
||||||
if (dto.getNum() != null) {
|
|
||||||
while (codeList.size() < dto.getNum()) {
|
|
||||||
String code = FieldGenerator.generateField();
|
|
||||||
int count = selectByCode(code);
|
|
||||||
if (count == 0 && !codeList.contains(code)) {
|
|
||||||
codeList.add(code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int res;
|
int res;
|
||||||
try {
|
try {
|
||||||
//1. 判断是数量还是编号入库,保存到不同表
|
//1. 判断是数量还是编号入库,保存到不同表
|
||||||
//1.1 如果是编号入库
|
//1.1 如果是编号入库
|
||||||
if (dto.getIsCode()) {
|
if (dto.getIsCode()) {
|
||||||
res = insertMaMachineInfo(dto, codeList);
|
res = insertMaMachineInfo(dto, code);
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
log.error("insertMaMachineInfo方法插入异常");
|
log.error("insertMaMachineInfo方法插入异常");
|
||||||
throw new RuntimeException("insertMaMachineInfo方法插入异常");
|
throw new RuntimeException("insertMaMachineInfo方法插入异常");
|
||||||
|
|
@ -78,7 +91,7 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//2.插入ma_type_put_in_storage_info表和ma_type_put_in_storage_details表
|
//2.插入ma_type_put_in_storage_info表和ma_type_put_in_storage_details表
|
||||||
res = insertPutInfo(dto);
|
res = insertPutInfo(dto, code);
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
log.error("insertPutInfo方法插入异常");
|
log.error("insertPutInfo方法插入异常");
|
||||||
throw new RuntimeException("insertPutInfo方法插入异常");
|
throw new RuntimeException("insertPutInfo方法插入异常");
|
||||||
|
|
@ -105,14 +118,13 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi
|
||||||
/**
|
/**
|
||||||
* 编号新增,插入ma_machine、ma_machine_label和ma_label_bind
|
* 编号新增,插入ma_machine、ma_machine_label和ma_label_bind
|
||||||
* @param dto
|
* @param dto
|
||||||
* @param codeList
|
* @param code
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private int insertMaMachineInfo(SavePutInfoDto dto, List<String> codeList) {
|
private int insertMaMachineInfo(SavePutInfoDto dto, String code) {
|
||||||
int res = 0;
|
int res = 0;
|
||||||
for (int i = 0; i < dto.getMachIneDtoList().size(); i++) {
|
for (int i = 0; i < dto.getMachIneDtoList().size(); i++) {
|
||||||
MachIneDto machIneDto = dto.getMachIneDtoList().get(i);
|
MachIneDto machIneDto = dto.getMachIneDtoList().get(i);
|
||||||
String code = codeList.get(i);
|
|
||||||
machIneDto.setCode(code);
|
machIneDto.setCode(code);
|
||||||
machIneDto.setIsCode(dto.getIsCode());
|
machIneDto.setIsCode(dto.getIsCode());
|
||||||
machIneDto.setTypeId(dto.getTypeId());
|
machIneDto.setTypeId(dto.getTypeId());
|
||||||
|
|
@ -171,7 +183,7 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi
|
||||||
* @param dto
|
* @param dto
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private int insertPutInfo(SavePutInfoDto dto) {
|
private int insertPutInfo(SavePutInfoDto dto, String code) {
|
||||||
int res = 0;
|
int res = 0;
|
||||||
for (int i = 0; i < dto.getMachIneDtoList().size(); i++) {
|
for (int i = 0; i < dto.getMachIneDtoList().size(); i++) {
|
||||||
MachIneDto machIneDto = dto.getMachIneDtoList().get(i);
|
MachIneDto machIneDto = dto.getMachIneDtoList().get(i);
|
||||||
|
|
@ -180,6 +192,7 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi
|
||||||
machIneDto.setRemarks(dto.getRemarks());
|
machIneDto.setRemarks(dto.getRemarks());
|
||||||
machIneDto.setUnitId(dto.getUnitId());
|
machIneDto.setUnitId(dto.getUnitId());
|
||||||
machIneDto.setProId(dto.getProId());
|
machIneDto.setProId(dto.getProId());
|
||||||
|
machIneDto.setCode(code);
|
||||||
res += insertTypePutInStorageInfo(machIneDto);
|
res += insertTypePutInStorageInfo(machIneDto);
|
||||||
//根据类型追加ma_type表里面的num
|
//根据类型追加ma_type表里面的num
|
||||||
res += updateMaTypeInfo(machIneDto.getTypeId(), machIneDto.getPutInStoreNum());
|
res += updateMaTypeInfo(machIneDto.getTypeId(), machIneDto.getPutInStoreNum());
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@
|
||||||
<if test="creator != null and creator != ''">CREATOR,</if>
|
<if test="creator != null and creator != ''">CREATOR,</if>
|
||||||
<if test="unitId != null and unitId != ''">UNIT_ID,</if>
|
<if test="unitId != null and unitId != ''">UNIT_ID,</if>
|
||||||
<if test="proId != null and proId != ''">PROJECT_ID,</if>
|
<if test="proId != null and proId != ''">PROJECT_ID,</if>
|
||||||
|
<if test="code != null and code != ''">CODE,</if>
|
||||||
CREATE_DATE,
|
CREATE_DATE,
|
||||||
<choose>
|
<choose>
|
||||||
<when test="isCode and remarks != null and remarks != ''">
|
<when test="isCode and remarks != null and remarks != ''">
|
||||||
|
|
@ -88,6 +89,7 @@
|
||||||
<if test="creator != null and creator != ''">#{creator},</if>
|
<if test="creator != null and creator != ''">#{creator},</if>
|
||||||
<if test="unitId != null and unitId != ''">#{unitId},</if>
|
<if test="unitId != null and unitId != ''">#{unitId},</if>
|
||||||
<if test="proId != null and proId != ''">#{proId},</if>
|
<if test="proId != null and proId != ''">#{proId},</if>
|
||||||
|
<if test="code != null and code != ''">#{code},</if>
|
||||||
sysdate(),
|
sysdate(),
|
||||||
<choose>
|
<choose>
|
||||||
<when test="isCode and remarks != null and remarks != ''">
|
<when test="isCode and remarks != null and remarks != ''">
|
||||||
|
|
@ -151,6 +153,7 @@
|
||||||
<if test="maId != null">ma_id,</if>
|
<if test="maId != null">ma_id,</if>
|
||||||
<if test="code != null">label_code,</if>
|
<if test="code != null">label_code,</if>
|
||||||
<if test="typeId != null">type_id,</if>
|
<if test="typeId != null">type_id,</if>
|
||||||
|
<if test="creator != null">binder,</if>
|
||||||
label_type,
|
label_type,
|
||||||
bind_time,
|
bind_time,
|
||||||
status
|
status
|
||||||
|
|
@ -159,6 +162,7 @@
|
||||||
<if test="maId != null">#{maId},</if>
|
<if test="maId != null">#{maId},</if>
|
||||||
<if test="code != null">#{code},</if>
|
<if test="code != null">#{code},</if>
|
||||||
<if test="typeId != null">#{typeId},</if>
|
<if test="typeId != null">#{typeId},</if>
|
||||||
|
<if test="creator != null">#{creator},</if>
|
||||||
9,
|
9,
|
||||||
now(),
|
now(),
|
||||||
1
|
1
|
||||||
|
|
@ -177,10 +181,11 @@
|
||||||
SELECT pisi.PUT_IN_TYPE as putInType,
|
SELECT pisi.PUT_IN_TYPE as putInType,
|
||||||
lot.lot_name as projectName,
|
lot.lot_name as projectName,
|
||||||
bui.unit_name as unitName,
|
bui.unit_name as unitName,
|
||||||
pisi.`CODE` as code,
|
pisi.`CODE` as kindName,
|
||||||
mt2.type_name as typeName,
|
mt2.type_name as typeName,
|
||||||
su.user_name as userName,
|
su.user_name as modelName,
|
||||||
pisi.CREATE_DATE as createDate
|
pisi.CREATE_DATE as createDate,
|
||||||
|
pisi.REMARKS as remark
|
||||||
FROM ma_type_put_in_storage_info pisi
|
FROM ma_type_put_in_storage_info pisi
|
||||||
LEFT JOIN ma_type_put_in_storage_details pisd on pisi.id = pisd.INFO
|
LEFT JOIN ma_type_put_in_storage_details pisd on pisi.id = pisd.INFO
|
||||||
LEFT JOIN bm_project_lot lot on lot.lot_id = pisi.PROJECT_ID
|
LEFT JOIN bm_project_lot lot on lot.lot_id = pisi.PROJECT_ID
|
||||||
|
|
@ -188,12 +193,28 @@
|
||||||
LEFT JOIN ma_type mt on mt.type_id = pisd.TYPE
|
LEFT JOIN ma_type mt on mt.type_id = pisd.TYPE
|
||||||
LEFT JOIN ma_type mt2 on mt2.type_id = mt.parent_id
|
LEFT JOIN ma_type mt2 on mt2.type_id = mt.parent_id
|
||||||
LEFT JOIN sys_user su on su.user_id = pisi.CREATOR
|
LEFT JOIN sys_user su on su.user_id = pisi.CREATOR
|
||||||
|
where
|
||||||
|
1 = 1
|
||||||
|
<if test="keyWord != null and keyWord != ''">
|
||||||
|
and (pisi.PUT_IN_TYPE like concat('%',#{keyWord},'%') or
|
||||||
|
lot.lot_name like concat('%',#{keyWord},'%') or
|
||||||
|
bui.unit_name like concat('%',#{keyWord},'%') or
|
||||||
|
mt2.type_name like concat('%',#{keyWord},'%') or
|
||||||
|
su.user_name like concat('%',#{keyWord},'%') or
|
||||||
|
pisd.REMARKS like concat('%',#{keyWord},'%')
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
order by pisi.CREATE_DATE desc
|
||||||
</select>
|
</select>
|
||||||
<select id="selectByCode" resultType="java.lang.Integer">
|
<select id="selectByCode" resultType="java.lang.Integer">
|
||||||
select count(*)
|
select count(*)
|
||||||
from ma_machine
|
from ma_machine
|
||||||
<where>
|
where
|
||||||
|
1 = 1
|
||||||
<if test="code != null "> and qr_code = #{code}</if>
|
<if test="code != null "> and qr_code = #{code}</if>
|
||||||
</where>
|
|
||||||
|
</select>
|
||||||
|
<select id="selectTaskNumByMonth" resultType="java.lang.Integer">
|
||||||
|
select count(*) from ma_type_put_in_storage_info where DATE_FORMAT(CREATE_DATE,'%y%m') = DATE_FORMAT(#{date},'%y%m')
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue