人工入库完成后更新点位当前存储容器类型,释放点位状态
							parent
							
								
									80922c0dc9
								
							
						
					
					
						commit
						bed5562bbc
					
				| 
						 | 
				
			
			@ -16,11 +16,14 @@
 | 
			
		|||
 | 
			
		||||
package com.youchain.utils;
 | 
			
		||||
 | 
			
		||||
import java.sql.Timestamp;
 | 
			
		||||
import java.text.ParseException;
 | 
			
		||||
import java.text.SimpleDateFormat;
 | 
			
		||||
import java.time.*;
 | 
			
		||||
import java.time.format.DateTimeFormatter;
 | 
			
		||||
import java.util.Calendar;
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
import java.util.TimeZone;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author: liaojinlong
 | 
			
		||||
| 
						 | 
				
			
			@ -123,6 +126,17 @@ public class DateUtil {
 | 
			
		|||
        return DFY_MD_HMS.format(localDateTime);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /** 时间,时区*/
 | 
			
		||||
    public static Timestamp parseLocalDateTimeZone(String utcTime, String timeZone) throws ParseException {
 | 
			
		||||
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
 | 
			
		||||
        //设置时区UTC
 | 
			
		||||
        df.setTimeZone(TimeZone.getTimeZone(timeZone));
 | 
			
		||||
        //格式化,转当地时区时间
 | 
			
		||||
        Date after = df.parse(utcTime);
 | 
			
		||||
        //Data转Time
 | 
			
		||||
        return new Timestamp(after.getTime());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 日期格式化 yyyy-MM-dd
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,8 +18,11 @@ package com.youchain.utils;
 | 
			
		|||
import cn.hutool.core.io.IoUtil;
 | 
			
		||||
import cn.hutool.core.util.IdUtil;
 | 
			
		||||
import cn.hutool.poi.excel.BigExcelWriter;
 | 
			
		||||
import cn.hutool.poi.excel.ExcelReader;
 | 
			
		||||
import cn.hutool.poi.excel.ExcelUtil;
 | 
			
		||||
import com.youchain.config.FileProperties;
 | 
			
		||||
import com.youchain.exception.BadRequestException;
 | 
			
		||||
import lombok.RequiredArgsConstructor;
 | 
			
		||||
import org.apache.poi.util.IOUtils;
 | 
			
		||||
import org.apache.poi.xssf.streaming.SXSSFSheet;
 | 
			
		||||
import org.slf4j.Logger;
 | 
			
		||||
| 
						 | 
				
			
			@ -42,6 +45,7 @@ import java.util.Map;
 | 
			
		|||
 * @author Liu Xue
 | 
			
		||||
 * @date 2018-12-27
 | 
			
		||||
 */
 | 
			
		||||
@RequiredArgsConstructor
 | 
			
		||||
public class FileUtil extends cn.hutool.core.io.FileUtil {
 | 
			
		||||
 | 
			
		||||
    private static final Logger log = LoggerFactory.getLogger(FileUtil.class);
 | 
			
		||||
| 
						 | 
				
			
			@ -178,7 +182,15 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
 | 
			
		|||
        }
 | 
			
		||||
        return file;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
//    private final FileProperties properties;
 | 
			
		||||
    public static List<Map<String, Object>> importUpload(MultipartFile multipartFile,FileProperties properties) {
 | 
			
		||||
        FileUtil.checkSize(properties.getMaxSize(), multipartFile.getSize());
 | 
			
		||||
        String suffix = FileUtil.getExtensionName(multipartFile.getOriginalFilename());
 | 
			
		||||
        String type = FileUtil.getFileType(suffix);
 | 
			
		||||
        File file = FileUtil.upload(multipartFile, properties.getPath().getPath() + type + File.separator);
 | 
			
		||||
        ExcelReader reader = ExcelUtil.getReader(file);
 | 
			
		||||
        return reader.readAll();
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 将文件名解析成文件的上传路径
 | 
			
		||||
     */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -56,6 +56,11 @@ public class BillType extends BaseEntity implements Serializable {
 | 
			
		|||
    @ApiModelProperty(value = "仓库")
 | 
			
		||||
    private Dept dept;
 | 
			
		||||
 | 
			
		||||
    @OneToOne
 | 
			
		||||
    @JoinColumn(name = "point_id")
 | 
			
		||||
    @ApiModelProperty(value = "点位")
 | 
			
		||||
    private Point point;
 | 
			
		||||
 | 
			
		||||
    @Column(name = "`type`")
 | 
			
		||||
    @ApiModelProperty(value = "类型")
 | 
			
		||||
    private String type;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -62,8 +62,7 @@ public class Box  extends BaseEntity implements Serializable {
 | 
			
		|||
    private Item item;
 | 
			
		||||
 | 
			
		||||
    @OneToOne
 | 
			
		||||
    @JoinColumn(name = "`point_id`",nullable = false)
 | 
			
		||||
    @NotNull
 | 
			
		||||
    @JoinColumn(name = "`point_id`")
 | 
			
		||||
    @ApiModelProperty(value = "点位")
 | 
			
		||||
    private Point point;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -94,7 +93,7 @@ public class Box  extends BaseEntity implements Serializable {
 | 
			
		|||
    private String lampStatus;
 | 
			
		||||
 | 
			
		||||
    @Column(name = "`lamp_code`")
 | 
			
		||||
    @ApiModelProperty(value = "业务类型")
 | 
			
		||||
    @ApiModelProperty(value = "操作方式")
 | 
			
		||||
    private String lampCode;
 | 
			
		||||
    public void copy(Box source){
 | 
			
		||||
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -90,7 +90,7 @@ public class Item extends BaseEntity implements Serializable {
 | 
			
		|||
    private String smallClass;
 | 
			
		||||
 | 
			
		||||
    @Column(name = "`good_type`")
 | 
			
		||||
    @ApiModelProperty(value = "物料类型")
 | 
			
		||||
    @ApiModelProperty(value = "存储库区")
 | 
			
		||||
    private String goodType;
 | 
			
		||||
 | 
			
		||||
    @Column(name = "`length`")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -58,10 +58,10 @@ public class Point extends BaseEntity implements Serializable {
 | 
			
		|||
    @ApiModelProperty(value = "备注")
 | 
			
		||||
    private String description;
 | 
			
		||||
    @Column(name = "`storage_type`")
 | 
			
		||||
    @ApiModelProperty(value = "存储类型")
 | 
			
		||||
    @ApiModelProperty(value = "当前容器")
 | 
			
		||||
    private String storageType;
 | 
			
		||||
    @Column(name = "`beat_code`")
 | 
			
		||||
    @ApiModelProperty(value = "冷却区区域编码")
 | 
			
		||||
    @ApiModelProperty(value = "双深位组")
 | 
			
		||||
    private String beatCode;
 | 
			
		||||
 | 
			
		||||
    @Column(name = "`item_code`")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,6 +18,7 @@ package com.youchain.basicdata.repository;
 | 
			
		|||
import com.youchain.basicdata.domain.Area;
 | 
			
		||||
import org.springframework.data.jpa.repository.JpaRepository;
 | 
			
		||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 | 
			
		||||
import org.springframework.data.jpa.repository.Query;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
* @website https://eladmin.vip
 | 
			
		||||
| 
						 | 
				
			
			@ -25,4 +26,6 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 | 
			
		|||
* @date 2023-08-14
 | 
			
		||||
**/
 | 
			
		||||
public interface AreaRepository extends JpaRepository<Area, Long>, JpaSpecificationExecutor<Area> {
 | 
			
		||||
    @Query(value = "SELECT a FROM Area a WHERE a.name = ?1 ")
 | 
			
		||||
    Area findByName(String areaName);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -16,6 +16,7 @@
 | 
			
		|||
package com.youchain.basicdata.repository;
 | 
			
		||||
 | 
			
		||||
import com.youchain.basicdata.domain.Point;
 | 
			
		||||
import com.youchain.utils.BizStatus;
 | 
			
		||||
import org.springframework.data.jpa.repository.JpaRepository;
 | 
			
		||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 | 
			
		||||
import org.springframework.data.jpa.repository.Query;
 | 
			
		||||
| 
						 | 
				
			
			@ -29,12 +30,20 @@ import java.util.Map;
 | 
			
		|||
* @date 2023-07-26
 | 
			
		||||
**/
 | 
			
		||||
public interface PointRepository extends JpaRepository<Point, Long>, JpaSpecificationExecutor<Point> {
 | 
			
		||||
    @Query(value = "SELECT p.* FROM base_point p WHERE p.enabled=1 and p.status='FREE'", nativeQuery = true)
 | 
			
		||||
    List<Point> getKyPointList();
 | 
			
		||||
    @Query(value = "SELECT p FROM Point p WHERE (?1 is null or ?1 = p.area.code) and p.type='STORAGE' and p.enabled=true and (p.storageType is null or length(p.storageType)=0) ", nativeQuery = false)
 | 
			
		||||
    List<Point> getKyPointList(String areaCode);
 | 
			
		||||
    /** 分配 库位*/
 | 
			
		||||
    @Query(value = "SELECT p FROM Point p WHERE p.area.code=?1 and p.enabled=true and p.storageType is not null")
 | 
			
		||||
    List<Point> findByAreaCode(String areaCode);
 | 
			
		||||
    @Query(value = "SELECT p FROM Point p WHERE p.code=?1 and p.enabled=true")
 | 
			
		||||
    /**成品区- 占用库位*/
 | 
			
		||||
    @Query(value = "SELECT p FROM Point p WHERE p.area.code=?1 and p.enabled=true and p.storageType is null " +
 | 
			
		||||
            " and p.status=?2 and p.type='STORAGE' order by p.beatCode,p.heat asc")
 | 
			
		||||
    List<Point> findByAreaCodeCp(String areaCode,String status);
 | 
			
		||||
    @Query(value = "SELECT p FROM Point p WHERE p.code=?1")
 | 
			
		||||
    Point findByCode(String code);
 | 
			
		||||
    @Query(value = "SELECT p FROM Point p WHERE p.type=?1 and p.area.code=?2 and p.enabled=true")
 | 
			
		||||
    Point findByTypeAndArea(String type,String areaCode);
 | 
			
		||||
    /** 查询深位是否有库存 */
 | 
			
		||||
    @Query(value = "SELECT p FROM Point p WHERE p.beatCode=?1 and p.enabled=true and p.storageType is not null and p.heat<?2")
 | 
			
		||||
    List<Point> findByBeatCode(String beatCode,double heat);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -71,8 +71,6 @@ public class PointController {
 | 
			
		|||
 | 
			
		||||
    private final AreaService areaService;
 | 
			
		||||
 | 
			
		||||
    private final FileProperties properties;
 | 
			
		||||
 | 
			
		||||
    @Log("导出数据")
 | 
			
		||||
    @ApiOperation("导出数据")
 | 
			
		||||
    @GetMapping(value = "/download")
 | 
			
		||||
| 
						 | 
				
			
			@ -86,9 +84,7 @@ public class PointController {
 | 
			
		|||
    @ApiOperation("导入点位")
 | 
			
		||||
    @PreAuthorize("@el.check('point:importPoint')")
 | 
			
		||||
    public ResponseEntity<Object> importPoint(@RequestParam("file") MultipartFile multipartFile) {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        FileUtil.checkSize(properties.getMaxSize(), multipartFile.getSize());
 | 
			
		||||
        /*FileUtil.checkSize(properties.getMaxSize(), multipartFile.getSize());
 | 
			
		||||
        String suffix = FileUtil.getExtensionName(multipartFile.getOriginalFilename());
 | 
			
		||||
        String type = FileUtil.getFileType(suffix);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -165,8 +161,9 @@ public class PointController {
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
        ApiError apiError = ApiError.errorJosn(HttpStatus.OK.value(), "导入成功:" + (i) + "行 新增(" + new_len + ")修改(" + edit_len + ")");
 | 
			
		||||
        return new ResponseEntity(apiError, HttpStatus.valueOf(apiError.getStatus()));
 | 
			
		||||
 | 
			
		||||
        return new ResponseEntity(apiError, HttpStatus.valueOf(apiError.getStatus()));*/
 | 
			
		||||
        ApiResult apiResult = pointService.importPoint(multipartFile);
 | 
			
		||||
        return new ResponseEntity<>(apiResult, HttpStatus.valueOf(apiResult.getStatus()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @GetMapping
 | 
			
		||||
| 
						 | 
				
			
			@ -186,18 +183,10 @@ public class PointController {
 | 
			
		|||
    }
 | 
			
		||||
    @PostMapping(value = "/getPointList")
 | 
			
		||||
    @AnonymousAccess
 | 
			
		||||
    public ResponseEntity<Object> getPointList() {
 | 
			
		||||
        return new ResponseEntity<>(pointRepository.getKyPointList(), HttpStatus.OK);
 | 
			
		||||
    public ResponseEntity<Object> getPointList(@RequestBody(required=false) String billCode) {
 | 
			
		||||
        List<Point> pointList=pointRepository.getKyPointList(billCode);
 | 
			
		||||
        return new ResponseEntity<>(pointList, HttpStatus.OK);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @GetMapping(value = "/queryKyPointList")
 | 
			
		||||
    @Log("查询可用空闲的点位point")
 | 
			
		||||
    @ApiOperation("查询可用空闲的点位point")
 | 
			
		||||
    @PreAuthorize("@el.check('point:list')")
 | 
			
		||||
    public ResponseEntity<Object> queryKyPointList(PointQueryCriteria criteria, Pageable pageable) {
 | 
			
		||||
        return new ResponseEntity<>(pointService.queryKyPointList(), HttpStatus.OK);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @PostMapping
 | 
			
		||||
    @Log("新增point")
 | 
			
		||||
    @ApiOperation("新增point")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,7 +21,11 @@ import com.youchain.basicdata.service.dto.ItemDto;
 | 
			
		|||
import com.youchain.basicdata.service.dto.PointDto;
 | 
			
		||||
import com.youchain.basicdata.service.dto.PointQueryCriteria;
 | 
			
		||||
import com.youchain.basicdata.service.dto.PointSmallDto;
 | 
			
		||||
import com.youchain.exception.handler.ApiError;
 | 
			
		||||
import com.youchain.exception.handler.ApiResult;
 | 
			
		||||
import org.springframework.data.domain.Pageable;
 | 
			
		||||
import org.springframework.web.multipart.MultipartFile;
 | 
			
		||||
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
| 
						 | 
				
			
			@ -50,13 +54,6 @@ public interface PointService {
 | 
			
		|||
    */
 | 
			
		||||
    List<PointDto> queryAll(PointQueryCriteria criteria);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询所有数据不分页
 | 
			
		||||
     * @return List<PointDto>
 | 
			
		||||
     */
 | 
			
		||||
    List<PointSmallDto> queryKyPointList();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据ID查询
 | 
			
		||||
     * @param id ID
 | 
			
		||||
| 
						 | 
				
			
			@ -161,4 +158,5 @@ public interface PointService {
 | 
			
		|||
     */
 | 
			
		||||
    Point getPointByFreeQH(String areaName,String goodType);
 | 
			
		||||
 | 
			
		||||
    ApiResult importPoint(MultipartFile multipartFile);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,6 +15,7 @@
 | 
			
		|||
*/
 | 
			
		||||
package com.youchain.basicdata.service.dto;
 | 
			
		||||
 | 
			
		||||
import com.youchain.basicdata.domain.Point;
 | 
			
		||||
import com.youchain.modules.system.domain.Dept;
 | 
			
		||||
import com.youchain.modules.system.service.dto.DeptSmallDto;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
| 
						 | 
				
			
			@ -56,6 +57,8 @@ public class BillTypeDto implements Serializable {
 | 
			
		|||
 | 
			
		||||
    /** 创建人 */
 | 
			
		||||
    private String createBy;
 | 
			
		||||
    /** 点位*/
 | 
			
		||||
    private Point point;
 | 
			
		||||
 | 
			
		||||
    /** 修改人 */
 | 
			
		||||
    private String updateBy;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,7 +43,7 @@ public class PointDto implements Serializable {
 | 
			
		|||
    /** 描述 */
 | 
			
		||||
    private String description;
 | 
			
		||||
 | 
			
		||||
    /** 区域编码 */
 | 
			
		||||
    /** 双深位组 */
 | 
			
		||||
    private String beatCode;
 | 
			
		||||
 | 
			
		||||
    /** 物料编码 */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,9 +21,13 @@ import com.youchain.appupdate.ReturnJson.RLocLayout;
 | 
			
		|||
import com.youchain.basicdata.domain.Area;
 | 
			
		||||
import com.youchain.basicdata.domain.Item;
 | 
			
		||||
import com.youchain.basicdata.domain.Point;
 | 
			
		||||
import com.youchain.basicdata.repository.AreaRepository;
 | 
			
		||||
import com.youchain.basicdata.service.dto.StockSmallDto;
 | 
			
		||||
import com.youchain.businessdata.ReturnJson.RPTaskList;
 | 
			
		||||
import com.youchain.businessdata.inputJson.IPTask;
 | 
			
		||||
import com.youchain.config.FileProperties;
 | 
			
		||||
import com.youchain.exception.handler.ApiError;
 | 
			
		||||
import com.youchain.exception.handler.ApiResult;
 | 
			
		||||
import com.youchain.modules.system.domain.DictDetail;
 | 
			
		||||
import com.youchain.utils.*;
 | 
			
		||||
import jdk.internal.dynalink.beans.StaticClass;
 | 
			
		||||
| 
						 | 
				
			
			@ -43,7 +47,9 @@ import org.springframework.stereotype.Service;
 | 
			
		|||
import org.springframework.transaction.annotation.Transactional;
 | 
			
		||||
import org.springframework.data.domain.Page;
 | 
			
		||||
import org.springframework.data.domain.Pageable;
 | 
			
		||||
import org.springframework.web.multipart.MultipartFile;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.util.stream.Collectors;
 | 
			
		||||
| 
						 | 
				
			
			@ -66,6 +72,7 @@ import javax.servlet.http.HttpServletResponse;
 | 
			
		|||
public class PointServiceImpl implements PointService {
 | 
			
		||||
 | 
			
		||||
    private final PointRepository pointRepository;
 | 
			
		||||
    private final AreaRepository areaRepository;
 | 
			
		||||
    private final PointMapper pointMapper;
 | 
			
		||||
    private final EntityManager entityMapper;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -79,15 +86,6 @@ public class PointServiceImpl implements PointService {
 | 
			
		|||
    public List<PointDto> queryAll(PointQueryCriteria criteria) {
 | 
			
		||||
        return pointMapper.toDto(pointRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<PointSmallDto> queryKyPointList() {
 | 
			
		||||
        List<Point> maps = pointRepository.getKyPointList();
 | 
			
		||||
        String irsStr = JSON.toJSONString(maps);
 | 
			
		||||
        List<PointSmallDto> evaUserResps = JSON.parseArray(irsStr, PointSmallDto.class);
 | 
			
		||||
        return evaUserResps;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<Point> getPoint(String type, String areaCode) {
 | 
			
		||||
        String hql = " from Point p where p.enabled=true and p.status='FREE' and  p.type='" + type + "' ";
 | 
			
		||||
| 
						 | 
				
			
			@ -144,12 +142,14 @@ public class PointServiceImpl implements PointService {
 | 
			
		|||
        for (PointDto point : all) {
 | 
			
		||||
            Map<String, Object> map = new LinkedHashMap<>();
 | 
			
		||||
            map.put("代码", point.getCode());
 | 
			
		||||
            /*map.put("名称", point.getName());
 | 
			
		||||
            map.put("状态", point.getStatus());
 | 
			
		||||
            map.put("名称", point.getName());
 | 
			
		||||
            map.put("类型", point.getType());
 | 
			
		||||
            map.put("库区", point.getArea().getName());
 | 
			
		||||
            map.put("状态", point.getStatus());
 | 
			
		||||
            map.put("当前容器", point.getStorageType());
 | 
			
		||||
            map.put("深浅位", point.getHeat());
 | 
			
		||||
            map.put("深浅位组", point.getBeatCode());
 | 
			
		||||
            map.put("是否启用", point.getEnabled());
 | 
			
		||||
            map.put("仓库名称", point.getDept().getName());
 | 
			
		||||
            map.put("类型", point.getType());*/
 | 
			
		||||
            list.add(map);
 | 
			
		||||
        }
 | 
			
		||||
        FileUtil.downloadExcel(list, response);
 | 
			
		||||
| 
						 | 
				
			
			@ -357,6 +357,57 @@ public class PointServiceImpl implements PointService {
 | 
			
		|||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
    private final FileProperties properties;
 | 
			
		||||
    @Override
 | 
			
		||||
    public ApiResult importPoint(MultipartFile multipartFile) {
 | 
			
		||||
        List<String> msgError= new ArrayList<>();
 | 
			
		||||
        int a=0;
 | 
			
		||||
        int b=0;
 | 
			
		||||
        int c=0;
 | 
			
		||||
        List<Map<String, Object>> mapList=FileUtil.importUpload(multipartFile,properties);
 | 
			
		||||
        for (int i = 0; i < mapList.size(); i++) {
 | 
			
		||||
            Map map=mapList.get(i);
 | 
			
		||||
            Point point;
 | 
			
		||||
            String code=(map.get("代码")+"").equals("null")||(map.get("代码")+"").length()<1? null : (map.get("代码")+"");
 | 
			
		||||
            String name=(map.get("名称")+"").equals("null")||(map.get("名称")+"").length()<1? null : (map.get("名称")+"");
 | 
			
		||||
            String type=(map.get("类型")+"").equals("null")||(map.get("类型")+"").length()<1? null : (map.get("类型")+"");
 | 
			
		||||
            String areaName=(map.get("库区")+"").equals("null")||(map.get("库区")+"").length()<1? null : (map.get("库区")+"");
 | 
			
		||||
            String status=(map.get("状态")+"").equals("null")||(map.get("状态")+"").length()<1? null : (map.get("状态")+"");
 | 
			
		||||
            String storageType=(map.get("当前容器")+"").equals("null")||(map.get("当前容器")+"").length()<1? null : (map.get("当前容器")+"");
 | 
			
		||||
            String heat=(map.get("深浅位")+"").equals("null")||(map.get("深浅位")+"").length()<1? null : (map.get("深浅位")+"");
 | 
			
		||||
            String beatCode=(map.get("双深位组")+"").equals("null")||(map.get("双深位组")+"").length()<1? null : (map.get("双深位组")+"");
 | 
			
		||||
            String enabled=(map.get("是否启用")+"").equals("null")||(map.get("是否启用")+"").length()<1? null : (map.get("是否启用")+"");
 | 
			
		||||
            String del=(map.get("删除")+"").equals("null")||(map.get("删除")+"").length()<1? null : (map.get("删除")+"");
 | 
			
		||||
            if (code!=null){
 | 
			
		||||
                point=pointRepository.findByCode(code);
 | 
			
		||||
                if (point==null){
 | 
			
		||||
                    point=new Point();
 | 
			
		||||
                    point.setDept(UserUtils.getDept());
 | 
			
		||||
                    c=c+1;
 | 
			
		||||
                }else {
 | 
			
		||||
                    b=b+1;
 | 
			
		||||
                }
 | 
			
		||||
                if (code!=null) point.setCode(code);
 | 
			
		||||
                if (name!=null) point.setName(name);
 | 
			
		||||
                if (type!=null) point.setType(type);
 | 
			
		||||
                if (areaName!=null) {
 | 
			
		||||
                    Area area=areaRepository.findByName(areaName);
 | 
			
		||||
                    point.setArea(area);
 | 
			
		||||
                }
 | 
			
		||||
                if (status!=null) point.setStatus(status);
 | 
			
		||||
                if (storageType!=null) point.setStorageType(storageType);
 | 
			
		||||
                if (heat!=null) point.setHeat(Double.valueOf(heat));
 | 
			
		||||
                if (beatCode!=null) point.setBeatCode(beatCode);
 | 
			
		||||
                if (enabled!=null) point.setEnabled(Boolean.valueOf(enabled));
 | 
			
		||||
                pointRepository.save(point);
 | 
			
		||||
                if (del!=null){
 | 
			
		||||
                    pointRepository.delete(point);
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return ApiResult.fail(200,"导入"+a+"行,新增"+b+"行,修改"+c+"行"+";异常信息"+msgError.toString(),null);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public List<Object[]> queryPointKmd() {
 | 
			
		||||
        List<Object[]> pointList = null;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -121,7 +121,7 @@ public class AsnDetail  extends BaseEntity implements Serializable {
 | 
			
		|||
    private String propC3;
 | 
			
		||||
 | 
			
		||||
    @Column(name = "`prop_c4`")
 | 
			
		||||
    @ApiModelProperty(value = "属性4")
 | 
			
		||||
    @ApiModelProperty(value = "入库方式")
 | 
			
		||||
    private String propC4;
 | 
			
		||||
 | 
			
		||||
    @Column(name = "`prop_c5`")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -58,7 +58,7 @@ public class ItemKey  extends BaseEntity implements Serializable {
 | 
			
		|||
    private String propC2;
 | 
			
		||||
 | 
			
		||||
    @Column(name = "`prop_c3`")
 | 
			
		||||
    @ApiModelProperty(value = "计划单号")
 | 
			
		||||
    @ApiModelProperty(value = "系统单号")
 | 
			
		||||
    private String propC3;
 | 
			
		||||
 | 
			
		||||
    @Column(name = "`prop_c4`")
 | 
			
		||||
| 
						 | 
				
			
			@ -72,6 +72,9 @@ public class ItemKey  extends BaseEntity implements Serializable {
 | 
			
		|||
    @Column(name = "`prop_c6`")
 | 
			
		||||
    @ApiModelProperty(value = "流水号")
 | 
			
		||||
    private String propC6;
 | 
			
		||||
    @Column(name = "`prop_c7`")
 | 
			
		||||
    @ApiModelProperty(value = "成品物料码")
 | 
			
		||||
    private String propC7;
 | 
			
		||||
 | 
			
		||||
    @Column(name = "`prop_d1`")
 | 
			
		||||
    @ApiModelProperty(value = "生产日期")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -107,7 +107,7 @@ public class Task  extends BaseEntity implements Serializable {
 | 
			
		|||
    private Point dstPoint;
 | 
			
		||||
 | 
			
		||||
    @Column(name = "`src_stock_code`")
 | 
			
		||||
    @ApiModelProperty(value = "源容器编码")
 | 
			
		||||
    @ApiModelProperty(value = "成品箱码")
 | 
			
		||||
    private String srcStockCode;
 | 
			
		||||
 | 
			
		||||
    @Column(name = "`dst_stock_code`")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -39,7 +39,9 @@ public interface AsnDetailRepository extends JpaRepository<AsnDetail, Long>, Jpa
 | 
			
		|||
            +" group by i.id ",nativeQuery = true)
 | 
			
		||||
    List<Map<String,Object>> findByAsn(String asnStatus, String billTypeCode);
 | 
			
		||||
    @Query("select d from AsnDetail d where d.asn.relatedBill1=?1 and d.item.code=?2 and d.orderQty>d.receivedQty")
 | 
			
		||||
    List<AsnDetail> findByAsnAndItem(String taskBillCode, String itemCode);
 | 
			
		||||
    List<AsnDetail> findByAsnAndItem(String relatedBill1, String itemCode);
 | 
			
		||||
    @Query("select d from AsnDetail d where d.asn.id=?1 and d.asn.status=?2")
 | 
			
		||||
    List<AsnDetail> findByAsnId(Long asnId,String asnStatus);
 | 
			
		||||
    @Query(value = "select d.* from data_asn_detail d where d.asn_id=?1 having sum(d.order_qty)<=sum(d.received_qty)",nativeQuery = true)
 | 
			
		||||
    List<AsnDetail> findByAsnId(Long asnId);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -30,4 +30,9 @@ import java.util.List;
 | 
			
		|||
public interface AsnRepository extends JpaRepository<Asn, Long>, JpaSpecificationExecutor<Asn> {
 | 
			
		||||
    @Query(value = "select a from Asn a where a.relatedBill1=?1")
 | 
			
		||||
    Asn findByRelatedBill1(String relatedBill1);
 | 
			
		||||
    /** 登记单号*/
 | 
			
		||||
    @Query(value = "select a from Asn a where a.relatedBill2=?1")
 | 
			
		||||
    Asn findByRelatedBill2(String relatedBill2);
 | 
			
		||||
    @Query(value = "select a from Asn a where a.billType.code=?1 and a.status = 'OPEN'")
 | 
			
		||||
    List<Asn> findByBillType(String billTypeCode);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -99,6 +99,6 @@ public interface TaskRepository extends JpaRepository<Task, Long>, JpaSpecificat
 | 
			
		|||
            +" and i.good_type=?3 "
 | 
			
		||||
            +" group by i.id ",nativeQuery = true)
 | 
			
		||||
    List<Map<String,Object>> findBySumPlanQty(String taskStatus,int beSkip,String goodType);
 | 
			
		||||
    @Query(value = "select t from Task t where t.taskStatus =?1 and t.beSkip=?2 and t.itemKey.item.goodType=?3")
 | 
			
		||||
    @Query(value = "select t from Task t where t.taskStatus =?1 and t.beSkip=?2 and t.taskType=?3")
 | 
			
		||||
    List<Task> findByItemType(String taskStatus, int beSkip, String goodType);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -18,6 +18,7 @@ package com.youchain.businessdata.rest;
 | 
			
		|||
import com.youchain.annotation.AnonymousAccess;
 | 
			
		||||
import com.youchain.annotation.Log;
 | 
			
		||||
import com.youchain.businessdata.domain.Asn;
 | 
			
		||||
import com.youchain.businessdata.repository.AsnRepository;
 | 
			
		||||
import com.youchain.businessdata.service.AsnService;
 | 
			
		||||
import com.youchain.businessdata.service.dto.AsnQueryCriteria;
 | 
			
		||||
import com.youchain.exception.handler.ApiResult;
 | 
			
		||||
| 
						 | 
				
			
			@ -44,6 +45,7 @@ import javax.servlet.http.HttpServletResponse;
 | 
			
		|||
public class AsnController {
 | 
			
		||||
 | 
			
		||||
    private final AsnService asnService;
 | 
			
		||||
    private final AsnRepository asnRepository;
 | 
			
		||||
 | 
			
		||||
    @Log("导出数据")
 | 
			
		||||
    @ApiOperation("导出数据")
 | 
			
		||||
| 
						 | 
				
			
			@ -94,10 +96,18 @@ public class AsnController {
 | 
			
		|||
        return new ResponseEntity<>(asnService.getAsnList(),HttpStatus.OK);
 | 
			
		||||
    }
 | 
			
		||||
    @PostMapping("/startAsn")
 | 
			
		||||
    @Log("开始收货")
 | 
			
		||||
    @Log("入库-占用库位")
 | 
			
		||||
    @AnonymousAccess
 | 
			
		||||
    public ResponseEntity<Object> startAsn(@RequestBody String id) {
 | 
			
		||||
        ApiResult apiResult = asnService.startAsn(id);
 | 
			
		||||
    public ResponseEntity<Object> startAsn(@RequestBody Long id) {
 | 
			
		||||
        Asn asn=asnRepository.getById(id);
 | 
			
		||||
        ApiResult apiResult = asnService.startAsn(asn);
 | 
			
		||||
        return new ResponseEntity<>(ApiResult.success(apiResult.getMessage(),apiResult.getData()), HttpStatus.valueOf(apiResult.getStatus()));
 | 
			
		||||
    }
 | 
			
		||||
    @PostMapping("/cancelAsn")
 | 
			
		||||
    @Log("入库-取消占用")
 | 
			
		||||
    @AnonymousAccess
 | 
			
		||||
    public ResponseEntity<Object> cancelAsn(@RequestBody String id) {
 | 
			
		||||
        ApiResult apiResult = asnService.cancelAsn(id);
 | 
			
		||||
        return new ResponseEntity<>(ApiResult.success(apiResult.getMessage(),apiResult.getData()), HttpStatus.valueOf(apiResult.getStatus()));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -29,12 +29,12 @@ public class InterfaceController {
 | 
			
		|||
    @ApiOperation("接收SAP入库单")
 | 
			
		||||
    @AnonymousAccess
 | 
			
		||||
    public ResponseEntity<Object> importAsnApi(@RequestBody JSONObject jsonObject) {
 | 
			
		||||
        asnDetailService.importAsnApi(jsonObject);
 | 
			
		||||
        return new ResponseEntity<>(ApiResult.success("",""), HttpStatus.OK);
 | 
			
		||||
        ApiResult apiResult = asnDetailService.importAsnApi(jsonObject);
 | 
			
		||||
        return new ResponseEntity<>(apiResult, HttpStatus.valueOf(apiResult.getStatus()));
 | 
			
		||||
    }
 | 
			
		||||
    @PostMapping("/importPtApi")
 | 
			
		||||
    @Log("接收SAP入库单")
 | 
			
		||||
    @ApiOperation("接收SAP入库单")
 | 
			
		||||
    @Log("接收SAP出库单")
 | 
			
		||||
    @ApiOperation("接收SAP出库单")
 | 
			
		||||
    @AnonymousAccess
 | 
			
		||||
    public ResponseEntity<Object> importPtApi(@RequestBody JSONObject jsonObject) {
 | 
			
		||||
        ApiResult apiResult = pickDetailService.importPtApi(jsonObject);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -76,6 +76,13 @@ public class TaskController {
 | 
			
		|||
        ApiResult apiResult = taskService.manualReceiving(request);
 | 
			
		||||
        return new ResponseEntity<>(ApiResult.success(apiResult.getMessage(),apiResult.getData()), HttpStatus.valueOf(apiResult.getStatus()));
 | 
			
		||||
    }
 | 
			
		||||
    @PostMapping("/devanRfid")
 | 
			
		||||
    @ApiOperation("解析RFID")
 | 
			
		||||
    @AnonymousAccess
 | 
			
		||||
    public ResponseEntity<Object> devanRfid(@RequestBody String rfid){
 | 
			
		||||
        ApiResult apiResult = taskService.devanRfid(rfid);
 | 
			
		||||
        return new ResponseEntity<>(apiResult, HttpStatus.valueOf(apiResult.getStatus()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @GetMapping(value = "/queryAsnTask")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -107,7 +107,7 @@ public interface AsnDetailService {
 | 
			
		|||
 | 
			
		||||
    boolean findByMo(String Mo);
 | 
			
		||||
 | 
			
		||||
    String importAsnApi(JSONObject jsonObject);
 | 
			
		||||
    ApiResult importAsnApi(JSONObject jsonObject);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 入库任务,更新入库单明细,入库单
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -94,10 +94,12 @@ public interface AsnService {
 | 
			
		|||
     * @param erTime 操作时间
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    Asn addAsn(BillType billType, String relatedBill1, String structure,String orderOrigin, Timestamp erTime);
 | 
			
		||||
    Asn addAsn(BillType billType, String relatedBill2, String structure,String orderOrigin, Timestamp erTime);
 | 
			
		||||
 | 
			
		||||
    List<Asn> getAsnList();
 | 
			
		||||
 | 
			
		||||
    //开始收货
 | 
			
		||||
    ApiResult startAsn(String id);
 | 
			
		||||
    ApiResult startAsn(Asn asn);
 | 
			
		||||
 | 
			
		||||
    ApiResult cancelAsn(String id);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -148,4 +148,6 @@ public interface TaskService {
 | 
			
		|||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    ApiResult picking(Long[] ids);
 | 
			
		||||
 | 
			
		||||
    ApiResult devanRfid(String rfid);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -487,7 +487,7 @@ public class AgvTaskServiceImpl implements AgvTaskService {
 | 
			
		|||
            if (agvTask.getJobType().equals(BizStatus.ASN)) {
 | 
			
		||||
                List<Map<String,Object>> taskMapList=taskRepository.findByAgvTask(agvTask.getId(),"ASN",1l);
 | 
			
		||||
                if (taskMapList.size()>0) {
 | 
			
		||||
                    /** 入库任务回调 生成库存*/
 | 
			
		||||
                    /** 入库任务回调 生成库存 */
 | 
			
		||||
                    Inventory inventory = inventoryService.asnAddInventory(taskMapList);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,6 +31,7 @@ import com.youchain.businessdata.domain.AsnDetail;
 | 
			
		|||
import com.youchain.businessdata.repository.AsnRepository;
 | 
			
		||||
import com.youchain.businessdata.repository.TaskRepository;
 | 
			
		||||
import com.youchain.businessdata.service.AsnService;
 | 
			
		||||
import com.youchain.exception.handler.ApiResult;
 | 
			
		||||
import com.youchain.utils.*;
 | 
			
		||||
import lombok.RequiredArgsConstructor;
 | 
			
		||||
import com.youchain.businessdata.repository.AsnDetailRepository;
 | 
			
		||||
| 
						 | 
				
			
			@ -44,6 +45,7 @@ import org.springframework.data.domain.Page;
 | 
			
		|||
import org.springframework.data.domain.Pageable;
 | 
			
		||||
 | 
			
		||||
import java.sql.Timestamp;
 | 
			
		||||
import java.text.ParseException;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import javax.persistence.EntityManager;
 | 
			
		||||
| 
						 | 
				
			
			@ -67,8 +69,6 @@ public class AsnDetailServiceImpl implements AsnDetailService {
 | 
			
		|||
    private final EntityManager entityMapper;
 | 
			
		||||
    private final TaskRepository taskRepository;
 | 
			
		||||
    private final ItemRepository itemRepository;
 | 
			
		||||
    private final ItemService itemService;
 | 
			
		||||
    private final StockService stockService;
 | 
			
		||||
    private final BillTypeRepository billTypeRepository;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
| 
						 | 
				
			
			@ -212,20 +212,26 @@ public class AsnDetailServiceImpl implements AsnDetailService {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String importAsnApi(JSONObject jsonObject) {
 | 
			
		||||
    public ApiResult importAsnApi(JSONObject jsonObject) {
 | 
			
		||||
        System.out.println("接收入库单:"+jsonObject);
 | 
			
		||||
        String relatedBill1=jsonObject.getString("expectedReceiptId");//入库单号
 | 
			
		||||
        String relatedBill2=jsonObject.getString("expectedReceiptId");//登记单号
 | 
			
		||||
        String erTime=jsonObject.getString("expectedReceiptDate");//操作时间
 | 
			
		||||
 | 
			
		||||
        String billTypeCode=jsonObject.getString("expectedReceiptType");//入库类型
 | 
			
		||||
        String structure=jsonObject.getString("owner");//货主
 | 
			
		||||
 | 
			
		||||
        List<BillType> billTypeList=billTypeRepository.findBySourceName(billTypeCode);
 | 
			
		||||
        if (billTypeList.size()<1){
 | 
			
		||||
            return "单据类型错误";
 | 
			
		||||
            return ApiResult.fail(500,"单据类型错误",null);
 | 
			
		||||
        }
 | 
			
		||||
        BillType billType=billTypeList.get(0);
 | 
			
		||||
        Timestamp er = Timestamp.valueOf(DateUtil.parseLocalDateTimeFormat(erTime, "yyyy-MM-dd HH:mm:ss"));
 | 
			
		||||
        Asn asn = asnService.addAsn(billType,relatedBill1,structure,"SAP推送",er);
 | 
			
		||||
        Timestamp er = null;
 | 
			
		||||
        try {
 | 
			
		||||
            er = DateUtil.parseLocalDateTimeZone(erTime, "UTC");
 | 
			
		||||
        } catch (ParseException e) {
 | 
			
		||||
            throw new RuntimeException(e);
 | 
			
		||||
        }
 | 
			
		||||
        Asn asn = asnService.addAsn(billType,relatedBill2,structure,"SAP推送",er);
 | 
			
		||||
 | 
			
		||||
        JSONArray erLineList = jsonObject.getJSONArray("erLine");
 | 
			
		||||
        for (int i = 0; i < erLineList.size(); i++) {
 | 
			
		||||
| 
						 | 
				
			
			@ -233,7 +239,7 @@ public class AsnDetailServiceImpl implements AsnDetailService {
 | 
			
		|||
            String itemCode=erLine.getString("productId");//料号
 | 
			
		||||
            Item item=itemRepository.findByCode(itemCode);
 | 
			
		||||
            if (item==null){
 | 
			
		||||
                return "没有查询到物料号:"+itemCode;
 | 
			
		||||
                return ApiResult.fail(500,"没有查询到物料号:"+itemCode,null);
 | 
			
		||||
            }
 | 
			
		||||
            String lineNo=erLine.getString("lineNumber");//行号
 | 
			
		||||
            String quantityExpected=erLine.getString("quantityExpected");//数量
 | 
			
		||||
| 
						 | 
				
			
			@ -261,24 +267,37 @@ public class AsnDetailServiceImpl implements AsnDetailService {
 | 
			
		|||
            asnDetail.setPropC3(attributeValue.get("loadUnitId")+"");
 | 
			
		||||
            asnDetailRepository.save(asnDetail);
 | 
			
		||||
        }
 | 
			
		||||
        return null;
 | 
			
		||||
        return ApiResult.fail(200,"成功",null);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void receivingAsnDetail(AsnDetail asnDetail, Double qty) {
 | 
			
		||||
        // 更新订单明细数量
 | 
			
		||||
        asnDetail.setReceivedQty(asnDetail.getReceivedQty()+qty);
 | 
			
		||||
        if (asnDetail.getOrderQty()<=asnDetail.getReceivedQty()){
 | 
			
		||||
        asnDetailRepository.save(asnDetail);
 | 
			
		||||
        // 跟新订单状态
 | 
			
		||||
        List<AsnDetail> asnDetailList=asnDetailRepository.findByAsnId(asnDetail.getAsn().getId());
 | 
			
		||||
        Asn asn=asnDetail.getAsn();
 | 
			
		||||
        if (asnDetailList.size()>0){
 | 
			
		||||
            asn.setStatus(BizStatus.RECEIVED);
 | 
			
		||||
        }else {
 | 
			
		||||
            asn.setStatus(BizStatus.RECEIVING);
 | 
			
		||||
        }
 | 
			
		||||
        asnRepository.save(asn);
 | 
			
		||||
        /*if (asnDetail.getOrderQty()<=asnDetail.getReceivedQty()){
 | 
			
		||||
            asnDetail.setStatus(BizStatus.RECEIVED);
 | 
			
		||||
            List<AsnDetail> asnDetailList=asnDetailRepository.findByAsnId(asnDetail.getAsn().getId(),BizStatus.RECEIVING);
 | 
			
		||||
            List<AsnDetail> asnDetailList=asnDetailRepository.findByAsnId(asnDetail.getAsn().getId());
 | 
			
		||||
            if (asnDetailList.size()<2){
 | 
			
		||||
                // 收货完成
 | 
			
		||||
                Asn asn=asnDetail.getAsn();
 | 
			
		||||
                asn.setStatus(BizStatus.RECEIVED);
 | 
			
		||||
                asnRepository.save(asn);
 | 
			
		||||
            }
 | 
			
		||||
        }else {
 | 
			
		||||
            // 明细 收货中
 | 
			
		||||
            asnDetail.setStatus(BizStatus.RECEIVING);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        asnDetailRepository.save(asnDetail);
 | 
			
		||||
        asnDetailRepository.save(asnDetail);*/
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,6 +16,9 @@
 | 
			
		|||
package com.youchain.businessdata.service.impl;
 | 
			
		||||
 | 
			
		||||
import com.youchain.basicdata.domain.BillType;
 | 
			
		||||
import com.youchain.basicdata.domain.Item;
 | 
			
		||||
import com.youchain.basicdata.domain.Point;
 | 
			
		||||
import com.youchain.basicdata.repository.PointRepository;
 | 
			
		||||
import com.youchain.businessdata.domain.Asn;
 | 
			
		||||
import com.youchain.businessdata.domain.AsnDetail;
 | 
			
		||||
import com.youchain.businessdata.repository.AsnDetailRepository;
 | 
			
		||||
| 
						 | 
				
			
			@ -50,6 +53,7 @@ public class AsnServiceImpl implements AsnService {
 | 
			
		|||
 | 
			
		||||
    private final AsnRepository asnRepository;
 | 
			
		||||
    private final AsnDetailRepository asnDetailRepository;
 | 
			
		||||
    private final PointRepository pointRepository;
 | 
			
		||||
    private final AsnMapper asnMapper;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
| 
						 | 
				
			
			@ -120,16 +124,18 @@ public class AsnServiceImpl implements AsnService {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Asn addAsn(BillType billType, String relatedBill1, String structure,String orderOrigin, Timestamp erTime) {
 | 
			
		||||
    public Asn addAsn(BillType billType, String relatedBill2, String structure,String orderOrigin, Timestamp erTime) {
 | 
			
		||||
        Asn asn;
 | 
			
		||||
        asn = asnRepository.findByRelatedBill1(relatedBill1);
 | 
			
		||||
        asn = asnRepository.findByRelatedBill2(relatedBill2);
 | 
			
		||||
        if (asn==null){
 | 
			
		||||
            asn = new Asn();
 | 
			
		||||
            asn.setStatus(BizStatus.OPEN);
 | 
			
		||||
        }
 | 
			
		||||
        asn.setBillType(billType);
 | 
			
		||||
        // 默认单号
 | 
			
		||||
        asn.setRelatedBill1(relatedBill2);
 | 
			
		||||
        asn.setDept(UserUtils.getDept());
 | 
			
		||||
        asn.setRelatedBill1(relatedBill1);
 | 
			
		||||
        asn.setRelatedBill2(relatedBill2);
 | 
			
		||||
        asn.setStructure(structure);
 | 
			
		||||
        asn.setOrderOrigin(orderOrigin);
 | 
			
		||||
        asn.setErTime(erTime);
 | 
			
		||||
| 
						 | 
				
			
			@ -143,15 +149,122 @@ public class AsnServiceImpl implements AsnService {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ApiResult startAsn(String id) {
 | 
			
		||||
        Asn asn=asnRepository.getById(Long.valueOf(id));
 | 
			
		||||
    public ApiResult startAsn(Asn asn) {
 | 
			
		||||
        List<String> datas=new ArrayList<>();
 | 
			
		||||
        if (asn.getStatus().equals(BizStatus.OPEN)) {
 | 
			
		||||
            asn.setStatus(BizStatus.RECEIVING);
 | 
			
		||||
            //占用库位
 | 
			
		||||
            List<AsnDetail> asnDetailList=asnDetailRepository.findByAsnId(asn.getId(), BizStatus.OPEN );
 | 
			
		||||
            if (asnDetailList.size()>0){
 | 
			
		||||
                for (int i = 0; i < asnDetailList.size(); i++) {
 | 
			
		||||
                    AsnDetail asnDetail=asnDetailList.get(i);
 | 
			
		||||
                    Item item = asnDetail.getItem();
 | 
			
		||||
                    Double zzsQty=item.getExtendD1();// 装载数
 | 
			
		||||
                    Double orderQty=asnDetail.getOrderQty()-asnDetail.getReceivedQty();// 订单数
 | 
			
		||||
                    double result = orderQty / zzsQty;
 | 
			
		||||
                    int floorNum = (int) Math.floor(result);// 整托数
 | 
			
		||||
                    // 成品入库 分配库位
 | 
			
		||||
                    List<Point> points=new ArrayList<>();
 | 
			
		||||
                    List<Point> pointList=pointRepository.findByAreaCodeCp(item.getGoodType(),BaseStatus.FREE);
 | 
			
		||||
                    for (int j = 0; j < pointList.size(); j++) {
 | 
			
		||||
                        if (points.size()>=floorNum){
 | 
			
		||||
                            // 整托数 分配完成
 | 
			
		||||
                            break;
 | 
			
		||||
                        }
 | 
			
		||||
                        Point point =pointList.get(j);
 | 
			
		||||
                        if (point.getHeat()==null||point.getHeat()==1){
 | 
			
		||||
                            //浅位 直接分配
 | 
			
		||||
                            points.add(point);
 | 
			
		||||
                            continue;
 | 
			
		||||
                        }else {
 | 
			
		||||
                            // 深位,查询浅位是否空闲
 | 
			
		||||
                            List<Point> pointListQ=pointRepository.findByBeatCode(point.getBeatCode(),point.getHeat());
 | 
			
		||||
                            if (pointListQ.size()>0){
 | 
			
		||||
                                // 浅位有库存
 | 
			
		||||
                                continue;
 | 
			
		||||
                            }
 | 
			
		||||
                            points.add(point);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    //添加任务
 | 
			
		||||
                    StringBuffer sb=new StringBuffer();
 | 
			
		||||
                    sb.append("明细行:"+asnDetail.getLineNo()+",分配库位【");
 | 
			
		||||
                    for (int j = 0; j < points.size(); j++) {
 | 
			
		||||
                        Point point=points.get(j);
 | 
			
		||||
                        sb.append(point.getCode()+",");
 | 
			
		||||
                        point.setStatus(BaseStatus.USED);
 | 
			
		||||
                        pointRepository.save(point);
 | 
			
		||||
                    }
 | 
			
		||||
                    sb.append("】剩余整托数"+(floorNum-points.size())+",未占用库位的余托数量"+orderQty % zzsQty+";");
 | 
			
		||||
                    datas.add(sb.toString());
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            //修改状态
 | 
			
		||||
            asn.setStatus(BizStatus.ACTIVE);
 | 
			
		||||
            asnRepository.save(asn);
 | 
			
		||||
        }else {
 | 
			
		||||
            //状态错误
 | 
			
		||||
           return ApiResult.success(500,"状态错误!",id);
 | 
			
		||||
            return ApiResult.success(500,"状态错误!",asn.getId());
 | 
			
		||||
        }
 | 
			
		||||
        return ApiResult.success(200,"操作成功!",id);
 | 
			
		||||
        return ApiResult.success(200,datas.toString(),asn.getId());
 | 
			
		||||
    }
 | 
			
		||||
    @Override
 | 
			
		||||
    public ApiResult cancelAsn(String id) {
 | 
			
		||||
        List<String> datas=new ArrayList<>();
 | 
			
		||||
        Asn asn=asnRepository.getById(Long.valueOf(id));
 | 
			
		||||
        if (asn.getStatus().equals(BizStatus.ACTIVE)) {
 | 
			
		||||
            //占用库位
 | 
			
		||||
            List<AsnDetail> asnDetailList=asnDetailRepository.findByAsnId(asn.getId(), BizStatus.ACTIVE);
 | 
			
		||||
            if (asnDetailList.size()>0){
 | 
			
		||||
                for (int i = 0; i < asnDetailList.size(); i++) {
 | 
			
		||||
                    AsnDetail asnDetail=asnDetailList.get(i);
 | 
			
		||||
                    Item item = asnDetail.getItem();
 | 
			
		||||
                    Double zzsQty=item.getExtendD1();// 装载数
 | 
			
		||||
                    Double orderQty=asnDetail.getOrderQty()-asnDetail.getReceivedQty();// 订单数
 | 
			
		||||
                    double result = orderQty / zzsQty;
 | 
			
		||||
                    int floorNum = (int) Math.floor(result);// 整托数
 | 
			
		||||
                    // 成品入库 分配库位
 | 
			
		||||
                    List<Point> points=new ArrayList<>();
 | 
			
		||||
                    List<Point> pointList=pointRepository.findByAreaCodeCp(item.getGoodType(),BaseStatus.USED);
 | 
			
		||||
                    for (int j = 0; j < pointList.size(); j++) {
 | 
			
		||||
                        if (points.size()>=floorNum){
 | 
			
		||||
                            // 整托数 分配完成
 | 
			
		||||
                            break;
 | 
			
		||||
                        }
 | 
			
		||||
                        Point point =pointList.get(j);
 | 
			
		||||
                        if (point.getHeat()==null||point.getHeat()==1){
 | 
			
		||||
                            //浅位 直接取消
 | 
			
		||||
                            points.add(point);
 | 
			
		||||
                            continue;
 | 
			
		||||
                        }else {
 | 
			
		||||
                            // 深位,查询浅位是否空闲
 | 
			
		||||
                            List<Point> pointListQ=pointRepository.findByBeatCode(point.getBeatCode(),point.getHeat());
 | 
			
		||||
                            if (pointListQ.size()>0){
 | 
			
		||||
                                // 浅位有库存
 | 
			
		||||
                                continue;
 | 
			
		||||
                            }
 | 
			
		||||
                            points.add(point);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    //添加任务
 | 
			
		||||
                    StringBuffer sb=new StringBuffer();
 | 
			
		||||
                    sb.append("单号:"+asnDetail.getAsn().getRelatedBill1()+"明细行:"+asnDetail.getLineNo()+",取消占用库位【");
 | 
			
		||||
                    for (int j = 0; j < points.size(); j++) {
 | 
			
		||||
                        Point point=points.get(j);
 | 
			
		||||
                        sb.append(point.getCode()+",");
 | 
			
		||||
                        point.setStatus(BaseStatus.FREE);
 | 
			
		||||
                        pointRepository.save(point);
 | 
			
		||||
                    }
 | 
			
		||||
                    sb.append("】");
 | 
			
		||||
                    datas.add(sb.toString());
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            //修改状态
 | 
			
		||||
            asn.setStatus(BizStatus.OPEN);
 | 
			
		||||
            asnRepository.save(asn);
 | 
			
		||||
        }else {
 | 
			
		||||
            //状态错误
 | 
			
		||||
            return ApiResult.success(500,"状态错误!",id);
 | 
			
		||||
        }
 | 
			
		||||
        return ApiResult.success(200,datas.toString(),id);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -218,7 +218,6 @@ public class InventoryServiceImpl implements InventoryService {
 | 
			
		|||
            Long ikID=Long.valueOf(taskMap.get("ikID")+"");
 | 
			
		||||
            Long pointId=Long.valueOf(taskMap.get("pointId")+"");
 | 
			
		||||
            Inventory inventory = getInventory(qty, ikID, pointId,BizStatus.RECEIVING_UP);
 | 
			
		||||
 | 
			
		||||
            String[] arrTaskIds=taskIds.split(",");
 | 
			
		||||
            for (int j = 0; j < arrTaskIds.length; j++) {
 | 
			
		||||
                Long taskId=Long.valueOf(arrTaskIds[j]+"");
 | 
			
		||||
| 
						 | 
				
			
			@ -227,6 +226,7 @@ public class InventoryServiceImpl implements InventoryService {
 | 
			
		|||
                task.setInventory(inventory);
 | 
			
		||||
                taskRepository.save(task);
 | 
			
		||||
            }
 | 
			
		||||
            return inventory;
 | 
			
		||||
        }
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -39,6 +39,7 @@ import com.youchain.businessdata.service.dto.TaskDto;
 | 
			
		|||
import com.youchain.businessdata.service.dto.TaskQueryCriteria;
 | 
			
		||||
import com.youchain.businessdata.service.mapstruct.TaskMapper;
 | 
			
		||||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
import org.checkerframework.checker.units.qual.A;
 | 
			
		||||
import org.hibernate.SQLQuery;
 | 
			
		||||
import org.hibernate.transform.AliasToEntityMapResultTransformer;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
| 
						 | 
				
			
			@ -284,23 +285,57 @@ public class TaskServiceImpl implements TaskService {
 | 
			
		|||
        String itemCode=rfids[0]+"";
 | 
			
		||||
        String propC1=rfids[1]+"";
 | 
			
		||||
        String propC2=rfids[2]+"";
 | 
			
		||||
        String propC3=rfids[3]+"";
 | 
			
		||||
        String propC3=rfids[3]+"";// 系统单号
 | 
			
		||||
        String propC4=rfids[4]+"";
 | 
			
		||||
        String propC5=rfids[5]+"";//16进制
 | 
			
		||||
        StringBuffer propC6=new StringBuffer();
 | 
			
		||||
        for (int i = 6; i < rfids.length; i++) {
 | 
			
		||||
            int decimalNumber = Integer.parseInt(rfids[i], 16);
 | 
			
		||||
            int decimalMin = Integer.parseInt("0001", 16);
 | 
			
		||||
            int decimalMax = Integer.parseInt("EA60", 16);
 | 
			
		||||
            if (decimalNumber>=decimalMin&&decimalNumber<=decimalMax){
 | 
			
		||||
        String propC5=rfids[5]+"";//16进制 供货数量
 | 
			
		||||
        StringBuffer propC6 = new StringBuffer();//流水号
 | 
			
		||||
        StringBuffer propC7 = new StringBuffer();//成品物料码
 | 
			
		||||
        int xs = 0;//成品收货-箱数
 | 
			
		||||
        int xs_d = 0;//成品收货-单箱数量
 | 
			
		||||
        Double xs_start_d = 0d;//成品收货-起始箱码
 | 
			
		||||
        Double xs_end_d=0d;//成品收货-终止箱码
 | 
			
		||||
        String propC6Title=null;//成品收货-成品码抬头
 | 
			
		||||
        Long propC6_start_d = 0l;//成品收货-成品码起始码
 | 
			
		||||
        Long propC6_end_d=0l;//成品收货-成品码终止码
 | 
			
		||||
        Asn asn=asnRepository.findByRelatedBill1(propC3);
 | 
			
		||||
        if (asn==null){
 | 
			
		||||
            return ApiResult.result(201, "没有入库单", "");
 | 
			
		||||
        }else {
 | 
			
		||||
            if (!asn.getStatus().equals(BizStatus.RECEIVING)&&!asn.getStatus().equals(BizStatus.ACTIVE)){
 | 
			
		||||
                return ApiResult.result(500, "入库单未激活", "");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (asn.getBillType().getCode().equals(BizStatus.FC_RK)){
 | 
			
		||||
            propC6Title=rfids[7].substring(0, 6);
 | 
			
		||||
            propC6_start_d=Long.valueOf(rfids[7].substring(6, rfids[7].length()-1));//起始成品码
 | 
			
		||||
            propC6_end_d=Long.valueOf(rfids[8].substring(6, rfids[8].length()-1));//终止成品码
 | 
			
		||||
            propC6.append(propC6_start_d+"-"+propC6_end_d);
 | 
			
		||||
            /*for (Long i = propC6_start_d; i < propC6_end_d; i++) {
 | 
			
		||||
                if (propC6.length()<1){
 | 
			
		||||
                    propC6.append(rfids[i]);
 | 
			
		||||
                    propC6.append(propC6Title+i);
 | 
			
		||||
                }else {
 | 
			
		||||
                    propC6.append(",");
 | 
			
		||||
                    propC6.append(rfids[i]);
 | 
			
		||||
                    propC6.append(","+propC6Title+i);
 | 
			
		||||
                }
 | 
			
		||||
            }*/
 | 
			
		||||
            xs = Integer.parseInt(rfids[9], 16);//箱数
 | 
			
		||||
            xs_start_d = Double.valueOf(rfids[10]);//料箱起始码
 | 
			
		||||
            xs_end_d = Double.valueOf(rfids[11]);//料箱终止码
 | 
			
		||||
            xs_d = Integer.parseInt(propC5, 16) / xs;//单箱数量
 | 
			
		||||
        }else {
 | 
			
		||||
            for (int i = 6; i < rfids.length; i++) {
 | 
			
		||||
                int decimalNumber = Integer.parseInt(rfids[i], 16);
 | 
			
		||||
                int decimalMin = Integer.parseInt("0001", 16);
 | 
			
		||||
                int decimalMax = Integer.parseInt("EA60", 16);
 | 
			
		||||
                if (decimalNumber >= decimalMin && decimalNumber <= decimalMax) {
 | 
			
		||||
                    if (propC6.length() < 1) {
 | 
			
		||||
                        propC6.append(rfids[i]);
 | 
			
		||||
                    } else {
 | 
			
		||||
                        propC6.append(",");
 | 
			
		||||
                        propC6.append(rfids[i]);
 | 
			
		||||
                    }
 | 
			
		||||
                } else {
 | 
			
		||||
                    System.out.println("无效RFID:" + rfids[i]);
 | 
			
		||||
                }
 | 
			
		||||
            }else {
 | 
			
		||||
                System.out.println("无效RFID:"+rfids[i]);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -308,14 +343,6 @@ public class TaskServiceImpl implements TaskService {
 | 
			
		|||
        if (item==null){
 | 
			
		||||
            return ApiResult.result(500, "没有物料", "");
 | 
			
		||||
        }
 | 
			
		||||
        Asn asn=asnRepository.findByRelatedBill1(propC3);
 | 
			
		||||
        if (asn==null){
 | 
			
		||||
            return ApiResult.result(201, "没有入库单", "");
 | 
			
		||||
        }else {
 | 
			
		||||
            if (!asn.getStatus().equals(BizStatus.RECEIVING)){
 | 
			
		||||
                return ApiResult.result(500, "入库单未激活", "");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (itemKeyRepository.getByItemKey(item.getId(),propC1,propC2,propC3,propC4,propC5,propC6.toString())!=null){
 | 
			
		||||
            return ApiResult.result(500, "重复读取", "");
 | 
			
		||||
        };
 | 
			
		||||
| 
						 | 
				
			
			@ -323,14 +350,36 @@ public class TaskServiceImpl implements TaskService {
 | 
			
		|||
        ItemKey itemKey=itemKeyService.getItemKey(item, propC1, propC2,propC3,propC4,propC5,propC6.toString());
 | 
			
		||||
        //获取流水号
 | 
			
		||||
        String[] lsh=itemKey.getPropC6().split(",");
 | 
			
		||||
        if (lsh.length!=itemKey.getIntPropC5()){
 | 
			
		||||
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
 | 
			
		||||
            return ApiResult.result(500, "流水号数量和供货数量不一致", "");
 | 
			
		||||
        int taskSum=0;// 生成task数量
 | 
			
		||||
        if (asn.getBillType().getCode().equals(BizStatus.FC_RK)){
 | 
			
		||||
            taskSum = xs;//按 料箱数量生成task
 | 
			
		||||
        }else {
 | 
			
		||||
            if (lsh.length!=itemKey.getIntPropC5()){
 | 
			
		||||
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
 | 
			
		||||
                return ApiResult.result(500, "流水号数量和供货数量不一致", "");
 | 
			
		||||
            }
 | 
			
		||||
            taskSum = lsh.length;//按 流水号数量生成task
 | 
			
		||||
        }
 | 
			
		||||
        for (int i = 0; i < lsh.length; i++) {
 | 
			
		||||
            Task task=new Task();
 | 
			
		||||
        for (int i = 0; i < taskSum; i++) {
 | 
			
		||||
            Task task = new Task();
 | 
			
		||||
            if (asn.getBillType().getCode().equals(BizStatus.FC_RK)){
 | 
			
		||||
                task.setPlanQty((double) xs_d);//单箱数量
 | 
			
		||||
                StringBuffer putCode=new StringBuffer();
 | 
			
		||||
                for (int j = 0; j < xs_d; j++) {
 | 
			
		||||
                    if (putCode.length()<1){
 | 
			
		||||
                        putCode.append(propC6Title+(propC6_start_d+j));
 | 
			
		||||
                    }else {
 | 
			
		||||
                        putCode.append(","+propC6Title+(propC6_start_d+j));
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                propC6_start_d=propC6_start_d+xs_d;
 | 
			
		||||
                task.setPutCode(putCode.toString());//箱内 流水号
 | 
			
		||||
                task.setSrcStockCode((xs_start_d+i)+"");
 | 
			
		||||
            }else {
 | 
			
		||||
                task.setPlanQty(1d);
 | 
			
		||||
                task.setPutCode(lsh[i]);
 | 
			
		||||
            }
 | 
			
		||||
            task.setItemKey(itemKey);
 | 
			
		||||
            task.setPlanQty(1d);
 | 
			
		||||
            task.setDept(UserUtils.getDept());
 | 
			
		||||
            task.setTaskStatus(BizStatus.RECEIVING);
 | 
			
		||||
            if (type.equals("AGV")) {
 | 
			
		||||
| 
						 | 
				
			
			@ -338,37 +387,43 @@ public class TaskServiceImpl implements TaskService {
 | 
			
		|||
            } else if (type.equals("RG")) {
 | 
			
		||||
                task.setBeSkip(0);
 | 
			
		||||
            }
 | 
			
		||||
            task.setPutCode(lsh[i]);
 | 
			
		||||
            task.setBillCode(propC3);
 | 
			
		||||
            task.setTaskType(BizStatus.ASN);
 | 
			
		||||
            Point startPoint=pointRepository.findByTypeAndArea(BaseStatus.PLATFORM,item.getGoodType());
 | 
			
		||||
            task.setTaskType(asn.getBillType().getCode());
 | 
			
		||||
            Point startPoint = pointRepository.findByTypeAndArea(BaseStatus.PLATFORM, item.getGoodType());
 | 
			
		||||
            task.setSrcPoint(startPoint);
 | 
			
		||||
            taskRepository.save(task);
 | 
			
		||||
        }
 | 
			
		||||
        return ApiResult.result(200, "操作成功", "");
 | 
			
		||||
        return ApiResult.result(200, "操作成功", asn.getBillType().getCode());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ApiResult manualReceiving(JSONObject request) {
 | 
			
		||||
        String rfid=request.getString("RFID");
 | 
			
		||||
        Point point= pointRepository.getById(request.getLong("pointId"));
 | 
			
		||||
        System.out.println("rfid:"+rfid);
 | 
			
		||||
        // 读取RFID生成Task
 | 
			
		||||
        String billTypeCode="";//单据类型
 | 
			
		||||
        ApiResult apiResult = readRfid(rfid, "RG");
 | 
			
		||||
        if (apiResult.getStatus()!=200){
 | 
			
		||||
            return apiResult;
 | 
			
		||||
        }else {
 | 
			
		||||
            if (apiResult.getStatus()==200){
 | 
			
		||||
                billTypeCode=apiResult.getData()+"";
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        // 分配Task库位
 | 
			
		||||
        List<Task> taskList=taskRepository.findByItemType(BizStatus.RECEIVING,0,BizStatus.BCP);
 | 
			
		||||
        List<Task> taskList=taskRepository.findByItemType(BizStatus.RECEIVING,0,billTypeCode);
 | 
			
		||||
        for (int i = 0; i < taskList.size(); i++) {
 | 
			
		||||
            Task task=taskList.get(i);
 | 
			
		||||
            getAsnTask(point, task);
 | 
			
		||||
            ApiResult api = getAsnTask(point, task);
 | 
			
		||||
            taskRepository.save(task);
 | 
			
		||||
        }
 | 
			
		||||
        // 生成库存
 | 
			
		||||
        List<Map<String,Object>> taskMapList=taskRepository.findByAgvTask(null,"ASN",0l);
 | 
			
		||||
        List<Map<String,Object>> taskMapList=taskRepository.findByAgvTask(null,billTypeCode,0l);
 | 
			
		||||
        Inventory inventory = inventoryService.asnAddInventory(taskMapList);
 | 
			
		||||
 | 
			
		||||
        // 更新当前点位 存储容器状态
 | 
			
		||||
        point.setStorageType(inventory.getItemKey().getItem().getGoodType());
 | 
			
		||||
        point.setStatus(BaseStatus.FREE);
 | 
			
		||||
        pointRepository.save(point);
 | 
			
		||||
        return ApiResult.result(200, "操作成功", "");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -433,4 +488,45 @@ public class TaskServiceImpl implements TaskService {
 | 
			
		|||
        inventoryService.pickDelInventory(taskList);
 | 
			
		||||
        return ApiResult.fail(200,"操作成功","");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ApiResult devanRfid(String rfid) {
 | 
			
		||||
        String[] rfids=rfid.split("\\|");
 | 
			
		||||
        JSONObject data=new JSONObject();
 | 
			
		||||
        if (rfids.length>4){
 | 
			
		||||
            String sku=rfids[0]+"";//sku
 | 
			
		||||
            String propC1=rfids[1]+"";
 | 
			
		||||
            String propC2=rfids[2]+"";
 | 
			
		||||
            String propC3=rfids[3]+"";// 系统单号
 | 
			
		||||
            String propC5=rfids[5]+"";// 收货数量(16禁止)
 | 
			
		||||
 | 
			
		||||
            Asn asn=asnRepository.findByRelatedBill1(propC3);
 | 
			
		||||
            if (asn!=null){
 | 
			
		||||
                if (asn.getBillType().getCode().equals(BizStatus.FC_RK)){
 | 
			
		||||
                    // 成品入库
 | 
			
		||||
                    if (rfids.length==13){
 | 
			
		||||
                        data.put("relatedBill1",asn.getRelatedBill1());
 | 
			
		||||
                        data.put("relatedBill2",asn.getRelatedBill2());
 | 
			
		||||
                        data.put("billType",asn.getBillType());
 | 
			
		||||
                        data.put("sku",sku);
 | 
			
		||||
                        List<AsnDetail> asnDetailList = asnDetailRepository.findByAsnAndItem(asn.getRelatedBill1(),sku);
 | 
			
		||||
                        double orderQty=0;
 | 
			
		||||
                        for (int i = 0; i < asnDetailList.size(); i++) {
 | 
			
		||||
                            orderQty=orderQty+asnDetailList.get(i).getOrderQty();
 | 
			
		||||
                        }
 | 
			
		||||
                        data.put("lineNos",asnDetailList.size());
 | 
			
		||||
                        data.put("RFID",rfid);
 | 
			
		||||
                        data.put("orderQty",orderQty);
 | 
			
		||||
                        data.put("billCode",BizStatus.CP);
 | 
			
		||||
                        data.put("receivedQty",Integer.parseInt(propC5, 16));
 | 
			
		||||
                    }else {
 | 
			
		||||
                        return ApiResult.fail(400,"rfid长度不为13","");
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }else {
 | 
			
		||||
                return ApiResult.fail(400,"未查询到系统单号","");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return ApiResult.fail(200,"操作成功",data);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,20 +15,30 @@
 | 
			
		|||
 */
 | 
			
		||||
package com.youchain.modules.quartz.task;
 | 
			
		||||
 | 
			
		||||
import com.alibaba.fastjson.JSONArray;
 | 
			
		||||
import com.alibaba.fastjson.JSONObject;
 | 
			
		||||
import com.youchain.annotation.AnonymousAccess;
 | 
			
		||||
import com.youchain.basicdata.domain.BillType;
 | 
			
		||||
import com.youchain.basicdata.domain.Point;
 | 
			
		||||
import com.youchain.basicdata.repository.BillTypeRepository;
 | 
			
		||||
import com.youchain.basicdata.repository.PointRepository;
 | 
			
		||||
import com.youchain.businessdata.domain.AgvTask;
 | 
			
		||||
import com.youchain.businessdata.domain.Asn;
 | 
			
		||||
import com.youchain.businessdata.repository.AgvTaskRepository;
 | 
			
		||||
import com.youchain.businessdata.repository.AsnRepository;
 | 
			
		||||
import com.youchain.businessdata.service.AgvTaskService;
 | 
			
		||||
import com.youchain.businessdata.service.AsnService;
 | 
			
		||||
import com.youchain.exception.handler.ApiResult;
 | 
			
		||||
import com.youchain.utils.BizStatus;
 | 
			
		||||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
import org.checkerframework.checker.units.qual.A;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.http.HttpStatus;
 | 
			
		||||
import org.springframework.http.ResponseEntity;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import org.springframework.transaction.annotation.Transactional;
 | 
			
		||||
import org.springframework.web.bind.annotation.PostMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestBody;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -47,18 +57,39 @@ import java.util.concurrent.BlockingQueue;
 | 
			
		|||
@RestController
 | 
			
		||||
@RequestMapping("/api/test")
 | 
			
		||||
public class TestTask {
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private AgvTaskRepository agvTaskRepository;
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private PointRepository pointRepository;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private AsnRepository asnRepository;
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private AsnService asnService;
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private  AgvTaskService agvTaskService;
 | 
			
		||||
 | 
			
		||||
    private static final int MAX_TASK_COUNT = 4;
 | 
			
		||||
    private static final long TIMEOUT_MS = 600000; // 10分钟,以毫秒为单位
 | 
			
		||||
    private long lastTaskTime = System.currentTimeMillis();
 | 
			
		||||
 | 
			
		||||
    /** 占用库位*/
 | 
			
		||||
    /*@PostMapping("/startAsn")
 | 
			
		||||
    @AnonymousAccess*/
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public ResponseEntity<Object> startAsn(String req){
 | 
			
		||||
        JSONArray data=new JSONArray();
 | 
			
		||||
        JSONObject jsonObject=JSONObject.parseObject(req);
 | 
			
		||||
        JSONArray billTypeArray=jsonObject.getJSONArray("billType");
 | 
			
		||||
        for (int i = 0; i < billTypeArray.size(); i++) {
 | 
			
		||||
            List<Asn> asnList=asnRepository.findByBillType(billTypeArray.getString(i));
 | 
			
		||||
            for (int j = 0; j < asnList.size(); j++) {
 | 
			
		||||
                Asn asn=asnList.get(j);
 | 
			
		||||
                ApiResult apiResult = asnService.startAsn(asn);
 | 
			
		||||
                data.add(apiResult);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ApiResult apiResult=ApiResult.fail(200,"操作成功",null);
 | 
			
		||||
        return new ResponseEntity<>(apiResult, HttpStatus.valueOf(apiResult.getStatus()));
 | 
			
		||||
    }
 | 
			
		||||
    @PostMapping("/asnTask")
 | 
			
		||||
    @AnonymousAccess
 | 
			
		||||
    public ResponseEntity<Object> asnTask(){
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -78,7 +78,7 @@ public class AuthorizationController {
 | 
			
		|||
    public ResponseEntity<Object> login(@Validated @RequestBody AuthUserDto authUser, HttpServletRequest request) throws Exception {
 | 
			
		||||
        // 密码解密
 | 
			
		||||
        String password = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, authUser.getPassword());
 | 
			
		||||
        // 查询验证码
 | 
			
		||||
        /*// 查询验证码
 | 
			
		||||
        String code = (String) redisUtils.get(authUser.getUuid());
 | 
			
		||||
        // 清除验证码
 | 
			
		||||
        redisUtils.del(authUser.getUuid());
 | 
			
		||||
| 
						 | 
				
			
			@ -87,7 +87,7 @@ public class AuthorizationController {
 | 
			
		|||
        }
 | 
			
		||||
        if (StringUtils.isBlank(authUser.getCode()) || !authUser.getCode().equalsIgnoreCase(code)) {
 | 
			
		||||
            throw new BadRequestException("验证码错误");
 | 
			
		||||
        }
 | 
			
		||||
        }*/
 | 
			
		||||
        UsernamePasswordAuthenticationToken authenticationToken =
 | 
			
		||||
                new UsernamePasswordAuthenticationToken(authUser.getUsername(), password);
 | 
			
		||||
        Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authenticationToken);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -62,4 +62,5 @@ public interface DictDetailService {
 | 
			
		|||
    List<DictDetailDto> getDictByName(String name);
 | 
			
		||||
 | 
			
		||||
    Map<String ,DictDetail> getDictDetailByName(String name);
 | 
			
		||||
    Map<String,Map<String,Object>> getDictDetailByName(List<String> dictName);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -92,6 +92,18 @@ public class DictDetailServiceImpl implements DictDetailService {
 | 
			
		|||
        return map;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Map<String,Map<String,Object>> getDictDetailByName(List<String> dictNames) {
 | 
			
		||||
        Map<String,Map<String,Object>> dickMap=new HashMap<>();
 | 
			
		||||
        for (int i = 0; i < dictNames.size(); i++) {
 | 
			
		||||
            Map<String,Object> dickDetail=new HashMap<>();
 | 
			
		||||
            List<DictDetail> dictDetailList= dictDetailRepository.findByDictName(dictNames.get(i));
 | 
			
		||||
            for (int j = 0; j < dictDetailList.size(); j++) {
 | 
			
		||||
                DictDetail dictDetail=dictDetailList.get(j);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,6 +17,7 @@ package com.youchain.modules.system.service.impl;
 | 
			
		|||
 | 
			
		||||
import cn.hutool.core.collection.CollectionUtil;
 | 
			
		||||
import com.youchain.modules.system.domain.Dict;
 | 
			
		||||
import com.youchain.modules.system.domain.DictDetail;
 | 
			
		||||
import com.youchain.modules.system.service.DictService;
 | 
			
		||||
import com.youchain.modules.system.service.dto.DictDetailDto;
 | 
			
		||||
import com.youchain.modules.system.service.dto.DictDto;
 | 
			
		||||
| 
						 | 
				
			
			@ -115,6 +116,7 @@ public class DictServiceImpl implements DictService {
 | 
			
		|||
        FileUtil.downloadExcel(list, response);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Dict getDictDescription(String name) {
 | 
			
		||||
        return dictRepository.getDictDescription(name);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,7 +28,7 @@ public  interface BaseStatus {
 | 
			
		|||
    public static String BOX = "BOX";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 点位类型-缓存点
 | 
			
		||||
     * 点位类型-存储点
 | 
			
		||||
     */
 | 
			
		||||
    public static String STORAGE = "STORAGE";
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -218,12 +218,11 @@ public  interface  BizStatus {
 | 
			
		|||
    String BCP="BCP";
 | 
			
		||||
    /** 成品*/
 | 
			
		||||
    String CP="CP";
 | 
			
		||||
    /** 成品入库*/
 | 
			
		||||
    String FC_RK="FC_RK";
 | 
			
		||||
    /** 料箱*/
 | 
			
		||||
    String LX="LX";
 | 
			
		||||
    String BCP_PT="BCP_PT";
 | 
			
		||||
    String CP_PT="CP_PT";
 | 
			
		||||
    String LX_PT="LX_PT";
 | 
			
		||||
 | 
			
		||||
    /** AGV出库*/
 | 
			
		||||
    String AGV_PT=" AGV_PT";
 | 
			
		||||
    /** 人工出库*/
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue