package thyyxxk.webserver.controller.medicine;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
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;
import thyyxxk.webserver.config.auth.PassToken;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.medicalinsurance.manage.inventory.InvinfoDelete;
import thyyxxk.webserver.entity.medicine.YpCodgDownload;
import thyyxxk.webserver.entity.medicine.YpCodgUpload;
import thyyxxk.webserver.entity.medicine.YpInvinfoModify;
import thyyxxk.webserver.entity.medicine.YpPurcinfoBought;
import thyyxxk.webserver.entity.medicine.YpSelinfoSold;
import thyyxxk.webserver.entity.medicine.YpTracCodg;
import thyyxxk.webserver.service.medicine.YpTracCodgService;

import java.util.List;
import java.util.Map;

/**
 * @ClassName YpTracCodgController
 * @Author hsh
 * @Date 2025/4/21 0021 10:56
 * @Version 1.0
 * @Description 药品追溯码上传相关
 **/
@RestController
@RequestMapping("/ypTracCodg")
public class YpTracCodgController {

    private final YpTracCodgService service;

    public YpTracCodgController(YpTracCodgService service) {
        this.service = service;
    }

    /**
     * @Description 查询药库/药房信息
     * @Author hsh
     * @return map
     * @Date 2025/5/29 0029 17:23
     */
    @GetMapping("/selectGroupNoInfo")
    public ResultVo<Map<String, Object>> selectGroupNoInfo(){
        return service.selectGroupNoInfo();
    }

    /**
     * @Description 查询供应商字典
     * @Author hsh
     * @return map
     * @Date 2025/6/30 0030 15:27
     */
    @GetMapping("/selectSupplyType")
    public ResultVo<Map<String, Object>> selectSupplyType(){
        return service.selectSupplyType();
    }

    /**
     * @Description 商品销售上传 3505A接口
     * @Author hsh
     * @param dto 参数
     * @return map
     * @Date 2025/5/19 0019 16:53
     */
    @PassToken
    @PostMapping("/uploadYpSaleGoodsData")
    public ResultVo<Map<String, Object>> uploadYpSaleGoodsData(@RequestBody @Validated YpTracCodg dto){
        return service.uploadYpSaleGoodsData(dto);
    }

    /**
     * @Description 根据流水号和数据类型删除商品信息 3507A接口
     * @Author hsh
     * @param dto 删除参数
     * @return map
     * @Date 2025/5/15 0015 16:57
     */
    @PassToken
    @PostMapping("/deleteYpGoodsData")
    public ResultVo<Map<String, Object>> deleteYpGoodsData(@RequestBody @Validated InvinfoDelete dto){
        return service.deleteYpGoodsData(dto);
    }

    /**
     * @Description 根据药品国家医保编码和机构批次流水号或者医药机构目录编码查询商品销售信息 3513
     * @Author hsh
     * @param dto 参数
     * @return map
     * @Date 2025/5/20 0020 9:36
     */
    @PassToken
    @PostMapping("/selectYpSalesGoods")
    public ResultVo<Map<String, Object>> selectYpSalesGoods(@RequestBody @Validated YpTracCodg dto){
        return service.selectYpSalesGoods(dto);
    }

    /**
     * @Description 根据药企供应商查询并更新药企追溯码下载信息
     * @Author hsh
     * @param dto 药企信用代码，名称等
     * @return list 药企追溯码下载信息
     * @Date 2025/6/9 0009 9:34
     */
    @PassToken
    @PostMapping("/selectDownloadCodgBchno")
    public ResultVo<Map<String, Object>> selectDownloadCodgBchno(@RequestBody @Validated YpCodgDownload dto){
        return service.selectDownloadCodgBchno(dto);
    }

    /**
     * @Description 根据入库/退货单号查询商品采购信息
     * @Author hsh
     * @param dto 入/出库单号或者药品编码
     * @return list 商品采购信息
     * @Date 2025/5/26 0026 16:36
     */
    @PostMapping("/selectYpPurchaseDetail")
    public ResultVo<List<YpPurcinfoBought>> selectYpPurchaseDetail(@RequestBody @Validated YpCodgUpload dto){
        return service.selectYpPurchaseDetail(dto);
    }

    /**
     * @Description 批量上传药品入库记录
     * @Author hsh
     * @param list 药品入库记录
     * @return map
     * @Date 2025/5/27 0027 15:01
     */
    @PostMapping("/uploadYpPurchaseBatch")
    public ResultVo<Map<String, Object>> uploadYpPurchaseBatch(@RequestBody @Validated List<YpPurcinfoBought> list){
        return service.uploadYpPurchaseBatch(list);
    }

    /**
     * @Description 批量上传药品退货记录
     * @Author hsh
     * @param list 药品退货记录
     * @return map
     * @Date 2025/5/27 0027 15:06
     */
    @PostMapping("/uploadYpPurchaseReturnBatch")
    public ResultVo<Map<String, Object>> uploadYpPurchaseReturnBatch(@RequestBody @Validated List<YpPurcinfoBought> list){
        return service.uploadYpPurchaseReturnBatch(list);
    }

    /**
     * @Description 根据id，type等删除上传信息
     * @Author hsh
     * @param uploadList 上传信息
     * @return map
     * @Date 2025/5/27 0027 20:19
     */
    @PostMapping("/deleteYpUploadBatch")
    public ResultVo<Map<String, Object>> deleteYpUploadBatch(@RequestBody @Validated List<YpCodgUpload> uploadList){
        return service.deleteYpUploadBatch(uploadList);
    }

    /**
     * @Description 更新药品退库发票号
     * @Author hsh
     * @param bought 药品退库发票号信息
     * @return map
     * @Date 2025/5/27 0027 22:41
     */
    @PostMapping("/saveYpInvoice")
    public ResultVo<Map<String, Object>> saveYpInvoice(@RequestBody @Validated YpPurcinfoBought bought){
        return service.saveYpInvoice(bought);
    }

    /**
     * @Description 根据病人信息查询商品销售/销售退货信息
     * @Author hsh
     * @param dto 病人信息
     * @return list
     * @Date 2025/5/29 0029 11:14
     */
    @PostMapping("/selectYpSelinfoDetail")
    public ResultVo<List<YpSelinfoSold>> selectYpSelinfoDetail(@RequestBody @Validated YpCodgUpload dto){
        return service.selectYpSelinfoDetail(dto);
    }

    /**
     * @Description 批量上传药品销售信息
     * @Author hsh
     * @param list 药品销售信息
     * @return map
     * @Date 2025/5/30 0030 9:16
     */
    @PostMapping("/uploadYpSelinfoBatch")
    public ResultVo<Map<String, Object>> uploadYpSelinfoBatch(@RequestBody @Validated List<YpSelinfoSold> list){
        return service.uploadYpSelinfoBatch(list);
    }

    /**
     * @Description 批量上传药品销售退货信息
     * @Author hsh
     * @param list 药品销售退货信息
     * @return map
     * @Date 2025/5/30 0030 9:23
     */
    @PostMapping("/uploadYpSelinfoReturnBatch")
    public ResultVo<Map<String, Object>> uploadYpSelinfoReturnBatch(@RequestBody @Validated List<YpSelinfoSold> list){
        return service.uploadYpSelinfoReturnBatch(list);
    }

    /**
     * @Description ai 查询库存变更记录
     * @Author hsh
     * @param dto 参数
     * @return list
     * @Date 2025/6/4 0004 16:02
     */
    @PostMapping("/selectYpInvinfoDetail")
    public ResultVo<List<YpInvinfoModify>> selectYpInvinfoDetail(@RequestBody @Validated YpCodgUpload dto){
        return service.selectYpInvinfoDetail(dto);
    }

    /**
     * @Description 批量上传药品库存变更信息
     * @Author hsh
     * @param list 药品库存变更信息
     * @return map
     * @Date 2025/6/4 0004 16:29
     */
    @PostMapping("/uploadYpInvinfoBatch")
    public ResultVo<Map<String, Object>> uploadYpInvinfoBatch(@RequestBody @Validated List<YpInvinfoModify> list){
        return service.uploadYpInvinfoBatch(list);
    }
    
}
