自动化立体仓库 - WMS系统
zyx
2024-04-16 6d75b9bda39c710153183844ba1e8effbb730de1
src/main/java/com/zy/asrs/controller/PlaController.java
@@ -18,6 +18,7 @@
import com.zy.common.entity.PlaExcel;
import com.zy.common.web.BaseController;
import lombok.Synchronized;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
@@ -27,12 +28,10 @@
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
@RestController
@Slf4j
public class PlaController extends BaseController {
    @Autowired
@@ -47,6 +46,8 @@
    private OrderDetlService orderDetlService;
    @Autowired
    private PlaLogService plaLogService;
    @Autowired
    private MatService matService;
    @RequestMapping(value = "/pla/list/auth")
    @ManagerAuth
@@ -56,8 +57,19 @@
                  @RequestParam Map<String, Object> param){
        excludeTrash(param);
        EntityWrapper<Pla> wrapper = new EntityWrapper<>();
        if(!Cools.isEmpty(param.get("brand"))){
            wrapper.eq("brand",param.get("brand"));
            param.remove("brand");
        }
        // 没有选择的时候默认不显示已出库的物料
        if (Cools.isEmpty(param.get("status"))) {
            wrapper.ne("status", "全部出库");
        }
        convert(param, wrapper);
        wrapper.orderBy("modify_time",false);
        wrapper.orderBy("batch",true).orderBy("package_no" ,true);
        allLike(Pla.class, param.keySet(), wrapper, condition);
        return R.ok(plaService.selectPage(new Page<>(curr, limit), wrapper));
    }
@@ -85,6 +97,7 @@
            BeanUtils.copyProperties(plaSave,plaLog);
            plaLog.setId(null);
            plaLog.setCreateTime(new Date());
            plaLog.setModifyUser(getUser().getUsername());
            plaLogService.insert(plaLog);
        });
@@ -96,8 +109,8 @@
    public R delete(@RequestBody List<Pla> plas) {
        System.out.println(plas.toString());
        plas.forEach(pla -> {
            if(!pla.getStatus().equals(GlobleParameter.PLA_STATUS_00) || pla.getStatus().equals(GlobleParameter.PLA_STATUS_0)){
                throw new CoolException("非待入库的数据无法被删除");
            if(!pla.getStatus().equals(GlobleParameter.PLA_STATUS_00) && !pla.getStatus().equals(GlobleParameter.PLA_STATUS_0) && !pla.getStatus().equals(GlobleParameter.PLA_STATUS_1)){
                throw new CoolException("已入库的数据无法被删除");
            }
            Pla plaSave = plaService.selectById(pla.getId());
            pla.setModifyTime(new Date());
@@ -107,6 +120,7 @@
            BeanUtils.copyProperties(plaSave,plaLog);
            plaLog.setId(null);
            plaLog.setCreateTime(new Date());
            plaLog.setModifyUser(getUser().getUsername());
            plaLogService.insert(plaLog);
        });
@@ -157,7 +171,7 @@
            plaService.updateById(pla);
            plaQtyService.insert(plaQty);
            //生成拣货单
            addPakOUT(plaQty);
            addPakOUT(plaQty,getUserId());
        };
@@ -199,7 +213,8 @@
            pla.setModifyTime(new Date());
            pla.setWeightAnfme(0.0);
            plaService.updateById(pla);
            SaasUtils.insertLog(1,pla.getLocNo(),pla.getBatch()+","+pla.getPackageNo(),anfme,getUser().getUsername());
            SaasUtils.insertLog(1,pla.getLocNo(),pla.getBrand(),anfme,getUser().getUsername(),
                    null,pla.getBatch(),pla.getPackageNo(),pla.getOwner(),pla.getWorkshop());
        });
        return R.ok();
@@ -248,6 +263,33 @@
        return R.ok("解除冻结成功");
    }
    @RequestMapping(value = "/matMaktxQuery/auth")
    @ManagerAuth
    public R queryMat(String condition) {
        EntityWrapper<Mat> wrapper = new EntityWrapper<>();
        wrapper.like("maktx", condition);
        Page<Mat> page = matService.selectPage(new Page<>(0, 10), wrapper);
        List<Map<String, Object>> result = new ArrayList<>();
        for (Mat mat : page.getRecords()){
            Map<String, Object> map = new HashMap<>();
            map.put("id", mat.getMaktx());
            map.put("value", mat.getMaktx());
            result.add(map);
        }
        return R.ok(result);
    }
    @RequestMapping(value = "/pla/statis/auth")
    @ManagerAuth
    public R statis(@RequestParam(defaultValue = "1")Integer curr,
                    @RequestParam(defaultValue = "10")Integer limit,
                    @RequestParam Map<String, Object> param) {
        Page<Pla> stockStatis = plaService.getStockStatisAll(toPage(curr, limit, param, Pla.class));
        return R.ok().add(stockStatis);
    }
    /**
     * excel导入模板下载
     */
@@ -273,8 +315,11 @@
        try {
            EasyExcel.read(file.getInputStream(), PlaExcel.class, listener).sheet().doRead();
        }catch (Exception e){
            throw new CoolException("导入的数据格式错误,原因:" + e.getMessage());
            e.printStackTrace();
            int index = listener.getIndex() - 1;
            throw new CoolException("导入的数据格式错误,原因:" + e.getMessage() + ",第" + index + ",数据格式不对");
        }
        log.info("导入修改信息输出:" + listener.getRecordLog());
        return R.ok("成功同步"+listener.getTotal()+"条pla物料数据");
    }
@@ -309,7 +354,7 @@
        }
    }
    private R addPakOUT(PlaQty plaQty){
    private R addPakOUT(PlaQty plaQty,Long userId){
        ManPakOut manPakOut=new ManPakOut();
        manPakOut.setWrkNo(plaQty.getOrderNo()+"-"+System.currentTimeMillis());
        manPakOut.setWrkSts((long)1);
@@ -317,7 +362,7 @@
        manPakOut.setMaktx(plaQty.getBrand());
        manPakOut.setLocNo(plaQty.getLocNo());
        manPakOut.setBatch(plaQty.getBatch());
        manPakOut.setBarcode(plaQty.getPackageNo());
        manPakOut.setBarcode(plaQty.getPackageNo() + "");
        manPakOut.setUuid(String.valueOf(System.currentTimeMillis()));
        manPakOut.setCreateTime(new Date());
        manPakOut.setUpdateTime(new Date());
@@ -326,6 +371,10 @@
        manPakOut.setStatus(0);
        manPakOut.setDocId(plaQty.getOrderDetlId());
        manPakOut.setNodeId(plaQty.getId());
        manPakOut.setCustName(plaQty.getCustomer());
        manPakOut.setCreateBy(userId);
        //预计发货时间
        manPakOut.setSpecs(plaQty.getPakoutTime());
        //manPakOut.setNodeId(plaQty.getOrderDetlId());
        manPakOutService.insert(manPakOut);
        return R.ok();