package com.mandi.fendan.controller; import java.util.List; import java.util.Map; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import com.mandi.basicconfig.mapper.FdRepertoryNexusMapper; import com.mandi.basicconfig.persist.FdRepertoryNexus; import com.mandi.common.Jacksonmethod; import com.mandi.common.RequestParam; import com.mandi.common.SessionMethod; import com.mandi.dao.common.ObjectResult; import com.mandi.dao.common.PageResult; @Controller("fd_repertorynexus_con") @RequestMapping(value="/repertorynexus",method={RequestMethod.POST}) public class Fd_RepertoryNexusController { @Resource private FdRepertoryNexusMapper rnper; /** * 成品库 * @param r * @param re * @return */ @RequestMapping(value = "/getallCkList.htm", method = {RequestMethod.POST }) @ResponseBody public String getList(HttpServletRequest r,HttpServletResponse re){ List> ckList = rnper.getAllCk(); PageResult> prr=new PageResult>(); prr.setCode(0); prr.setList(ckList); SessionMethod.writeresp(re, Jacksonmethod.tojson(prr, false)); return null; } /** * 选择的成品库 * @param r * @param re * @return */ @RequestMapping(value = "/getChooseList.htm", method = {RequestMethod.POST }) @ResponseBody public String getChooseList(HttpServletRequest r,HttpServletResponse re){ String sdepartNo=RequestParam.getSqlString(r, "sdepartNo"); List choosedCkList = rnper.getBySdepartNo(sdepartNo); PageResult prr=new PageResult(); prr.setCode(0); prr.setList(choosedCkList); SessionMethod.writeresp(re, Jacksonmethod.tojson(prr, false)); return null; } /** * 保存成品库 * @param r * @param re * @return */ @RequestMapping(value = "/saveItem.htm", method = {RequestMethod.POST }) @ResponseBody public String saveItem(HttpServletRequest r,HttpServletResponse re){ String sdepartNo=RequestParam.getSqlString(r, "code"); String ckNos=RequestParam.getString(r, "ckNos"); if(StringUtils.isNotBlank(sdepartNo)) { rnper.delRepertoryNexusBySdepartNo(sdepartNo); if(StringUtils.isNotBlank(ckNos)) { String[] ja=ckNos.split(","); for (String str : ja) { String ywdyNo=str.split("_")[0]; String ckNo=str.split("_")[1]; FdRepertoryNexus fdn=rnper.getbyckNoAndYwdyNo(ckNo, ywdyNo); if(fdn!=null) { if(!fdn.getSdepartNo().equals(sdepartNo)) { fdn.setSdepartNo(sdepartNo); rnper.updateRepertoryNexus(fdn); } }else { fdn=new FdRepertoryNexus(); fdn.setCkNo(ckNo); fdn.setSdepartNo(sdepartNo); fdn.setYwdyNo(ywdyNo); rnper.insertRepertoryNexus(fdn); } } } } ObjectResult orr=new ObjectResult(); orr.setCode(0); orr.setItem(true); SessionMethod.writeresp(re, Jacksonmethod.tojson(orr, false)); return null; } }