王佳豪
2021-03-09 cc344f433bf14d966207255ac0c8f93a9a46dec2
src/main/java/com/zy/asrs/controller/LocNormalController.java
@@ -11,6 +11,7 @@
import com.core.common.DateUtils;
import com.core.common.R;
import com.zy.asrs.entity.LocNormal;
import com.zy.asrs.entity.param.LocNormalParam;
import com.zy.asrs.service.LocNormalService;
import com.zy.common.utils.excel.locNomal.LocNormalExcel;
import com.zy.common.utils.excel.locNomal.LocNormalExcelListener;
@@ -27,36 +28,39 @@
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import static jdk.nashorn.api.scripting.ScriptUtils.convert;
@RestController
public class LocNormalController extends BaseController{
public class LocNormalController extends BaseController {
    @Autowired
    private LocNormalService locNormalService;
    @RequestMapping(value = "/locNomal/list/auth")
    @ManagerAuth
    public R list(@RequestParam(defaultValue = "1")Integer curr,
                  @RequestParam(defaultValue = "10")Integer limit,
                  @RequestParam(required = false)String orderByField,
                  @RequestParam(required = false)String orderByType,
                  @RequestParam(required = false)String condition,
                  @RequestParam Map<String, Object> param){
    public R list(@RequestParam(defaultValue = "1") Integer curr,
                  @RequestParam(defaultValue = "10") Integer limit,
                  @RequestParam(required = false) String orderByField,
                  @RequestParam(required = false) String orderByType,
                  @RequestParam(required = false) String condition,
                  @RequestParam Map<String, Object> param) {
        excludeTrash(param);
        EntityWrapper<LocNormal> wrapper = new EntityWrapper<>();
        convert(param, wrapper);
        allLike(LocNormal.class, param.keySet(), wrapper, condition);
        if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));}
        if (!Cools.isEmpty(orderByField)) {
            wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));
        }
        wrapper.eq("state", "1").or().eq("state", "2");
        return R.ok(locNormalService.selectPage(new Page<>(curr, limit), wrapper));
    }
    private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){
        for (Map.Entry<String, Object> entry : map.entrySet()){
    private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper) {
        for (Map.Entry<String, Object> entry : map.entrySet()) {
            String val = String.valueOf(entry.getValue());
            if (val.contains(RANGE_TIME_LINK)){
            if (val.contains(RANGE_TIME_LINK)) {
                String[] dates = val.split(RANGE_TIME_LINK);
                wrapper.ge(entry.getKey(), DateUtils.convert(dates[0]));
                wrapper.le(entry.getKey(), DateUtils.convert(dates[1]));
@@ -84,7 +88,7 @@
    @ManagerAuth
    public R query(@RequestBody JSONObject param) {
        Wrapper<LocNormal> wrapper = new EntityWrapper<LocNormal>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val"));
        if (null != locNormalService.selectOne(wrapper)){
        if (null != locNormalService.selectOne(wrapper)) {
            return R.parse(BaseRes.REPEAT).add(getComment(LocNormal.class, String.valueOf(param.get("key"))));
        }
        return R.ok();
@@ -114,13 +118,28 @@
        locNormalService.removeLocNormal(param.getMatnr(), modiUser, modiTime);
    }
    // 导入
    /* 导入 */
    @RequestMapping(value = "/locNormal/import/auth")
    @ManagerAuth(memo = "平仓管理导入")
    @Transactional
    public R matCodeImport(MultipartFile file) throws IOException, InterruptedException {
    public R locNormalImport(MultipartFile file) throws IOException, InterruptedException {
        LocNormalExcelListener listener = new LocNormalExcelListener(getUserId());
        EasyExcel.read(file.getInputStream(), LocNormalExcel.class, listener).sheet().doRead();
        return R.ok("成功导入"+listener.getTotal()+"条物料信息");
        return R.ok("成功导入" + listener.getTotal() + "条物料信息");
    }
    /* pda入库 */
    @RequestMapping(value = "/locNormal/pda/in")
    @ManagerAuth(memo = "平仓管理pda入库")
    @Transactional
    public R locNormalPdaIn(@RequestBody LocNormalParam param) {
        Long userId = getUserId();
        Date timeNow = new Date();
        for (Integer i = 0; i < param.getNormalList().size(); i++) {
            param.getNormalList().get(i).setAppeUser(userId);
            param.getNormalList().get(i).setAppeTime(timeNow);
        }
        locNormalService.pdaLocNormalIn(param.getNormalList());
        return R.ok();
    }
}