ManufacturerInfoController.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. //package com.dragoninfo.dcuc.authweb.restcontroller.app;
  2. //
  3. //import cn.hutool.core.bean.BeanUtil;
  4. //import com.dragoninfo.dcuc.app.entity.ApplyInfo;
  5. //import com.dragoninfo.dcuc.app.entity.ManufacturerInfo;
  6. //import com.dragoninfo.dcuc.app.facade.IApplyInfoFacade;
  7. //import com.dragoninfo.dcuc.app.facade.IManufacturerInfoFacade;
  8. //import com.dragoninfo.dcuc.authweb.business.impl.MtAuthBusiness;
  9. //import com.dragoninfo.dcuc.authweb.common.SysConstants;
  10. //import com.dragoninfo.dcuc.authweb.restcontroller.app.vo.ManufacturerVo;
  11. //import com.dragoninfo.dcuc.org.facade.IOrgInfoFacade;
  12. //import com.dragoninfo.dcuc.org.vo.OrgTreeNode;
  13. //import com.dragoninfo.dcuc.user.user.entity.UserInfo;
  14. //import com.dragoninfo.dcuc.user.user.enumresources.UserTypeEnum;
  15. //import com.dragoninfo.dcuc.user.user.facade.IUserInfoFacade;
  16. //import com.dragoninfo.duceap.commons.util.server.OrgInfoUtil;
  17. //import com.dragoninfo.duceap.core.enums.ResultEnum;
  18. //import com.dragoninfo.duceap.core.response.Result;
  19. //import com.dragonsoft.duceap.base.entity.metadata.CodeRecord;
  20. //import com.dragonsoft.duceap.base.entity.search.SearchDTO;
  21. //import com.dragonsoft.duceap.base.entity.security.BaseSecurityUser;
  22. //import com.dragonsoft.duceap.core.context.ContextUtils;
  23. //import com.dragonsoft.duceap.core.search.Searchable;
  24. //import com.dragonsoft.duceap.web.controller.BaseController;
  25. //import io.swagger.annotations.Api;
  26. //import io.swagger.annotations.ApiImplicitParam;
  27. //import io.swagger.annotations.ApiImplicitParams;
  28. //import io.swagger.annotations.ApiOperation;
  29. //import org.springframework.beans.factory.annotation.Autowired;
  30. //import org.springframework.data.domain.Page;
  31. //import org.springframework.web.bind.annotation.*;
  32. //
  33. //import java.util.*;
  34. //
  35. ///**
  36. // * @author yica
  37. // * @date 2018/8/8
  38. // */
  39. //@Api(tags = {"厂商管理接口"})
  40. //@RestController
  41. //@RequestMapping(value = "/appsvr/v2")
  42. //public class ManufacturerInfoController extends BaseController<ManufacturerInfo, String> {
  43. //
  44. // @Autowired
  45. // private IManufacturerInfoFacade manufacturerInfoFacade;
  46. // @Autowired
  47. // private IApplyInfoFacade applyInfoFacade;
  48. // @Autowired
  49. // private MtAuthBusiness mtAuthBusiness;
  50. //
  51. // @Autowired
  52. // private IOrgInfoFacade orgInfoFacade;
  53. // @Autowired
  54. // private IUserInfoFacade userInfoFacade;
  55. //
  56. // @ApiOperation(value = "厂商查询列表")
  57. // @ApiImplicitParam(name = "searchable", value = "查询条件")
  58. // @PostMapping(value = "manufacturers")
  59. // public Result<List<ManufacturerInfo>> list(SearchDTO searchDTO) {
  60. // Searchable searchable = Searchable.toSearchable(searchDTO);
  61. // Page<ManufacturerInfo> page = manufacturerInfoFacade.manufacturerInfoPage(searchable.toSearchDTO());
  62. // return Result.success(page.getTotalElements(), page.getContent());
  63. // }
  64. //
  65. // @ApiOperation(value = "获取厂商")
  66. // @ApiImplicitParams({@ApiImplicitParam(paramType = "path", name = "id", value = "厂商ID", required = true
  67. // , example = "40288a8b699fc2500169a33b20540000")})
  68. // @GetMapping(value = "manufacturer/{id}")
  69. // public Result<ManufacturerVo> detail(@PathVariable("id") String id) {
  70. // ManufacturerVo manufacturerVo = new ManufacturerVo();
  71. // ManufacturerInfo manufacturerInfo = manufacturerInfoFacade.manufacturerInfoDetail(id);
  72. // BeanUtil.copyProperties(manufacturerInfo, manufacturerVo);
  73. // return Result.success(manufacturerVo);
  74. // }
  75. //
  76. // @ApiOperation(value = "修改厂商")
  77. // @ApiImplicitParam(name = "manufacturerVo", value = "厂商vo")
  78. // @PutMapping(value = "/manufacturer/{id}")
  79. // public Result<Object> update(@RequestBody ManufacturerVo manufacturerVo) {
  80. // try {
  81. // String id = manufacturerVo.getId();
  82. // String manufacturerName = manufacturerVo.getManufacturerName();
  83. // String code = manufacturerVo.getCode();
  84. //
  85. // ManufacturerInfo old = manufacturerInfoFacade.manufacturerInfoDetail(id);
  86. // String oldManufacturerName = old.getManufacturerName();
  87. // String oldCode = old.getCode();
  88. //
  89. // //厂商名称是否被修改
  90. // if (!oldManufacturerName.equals(manufacturerName)) {
  91. // List<ApplyInfo> appList = applyInfoFacade.getAppListByManufacturerId(id);
  92. // if (null != appList && (!appList.isEmpty())) {
  93. // return Result.fail(ResultEnum.SERVICE_FAIL.getValue(), "厂商已被引用,名称不可修改!");
  94. // }
  95. // if (isManufacturerName(manufacturerVo.getManufacturerName())) {
  96. // return Result.fail(ResultEnum.SERVICE_FAIL.getValue(), "厂商名称已被创建");
  97. // }
  98. // }
  99. // if (!code.equals(oldCode) && isCodeExist(code)) {
  100. // return Result.fail(ResultEnum.SERVICE_FAIL.getValue(), "组织机构代码已存在");
  101. // }
  102. // BeanUtil.copyProperties(manufacturerVo, old);
  103. // manufacturerInfoFacade.updateManufacturer(old);
  104. // } catch (Exception e) {
  105. // logger.error("manufacturer update", e);
  106. // return Result.fail(ResultEnum.SERVICE_FAIL.getValue(), "保存异常");
  107. // }
  108. // return Result.success();
  109. // }
  110. //
  111. // @ApiOperation(value = "保存厂商")
  112. // @ApiImplicitParam(name = "manufacturerVo", value = "厂商vo")
  113. // @PostMapping(value = "/manufacturer")
  114. // public Result<Object> save(@RequestBody ManufacturerVo manufacturerVo) {
  115. // try {
  116. // if (isManufacturerName(manufacturerVo.getManufacturerName())) {
  117. // return Result.fail(ResultEnum.SERVICE_FAIL.getValue(), "厂商名称已被创建");
  118. // }
  119. // if (isCodeExist(manufacturerVo.getCode())) {
  120. // return Result.fail(ResultEnum.SERVICE_FAIL.getValue(), "组织机构代码已存在");
  121. // }
  122. // ManufacturerInfo manufacturerInfo = new ManufacturerInfo();
  123. // BeanUtil.copyProperties(manufacturerVo, manufacturerInfo);
  124. //
  125. // manufacturerInfoFacade.saveManufacturer(manufacturerInfo);
  126. // } catch (Exception e) {
  127. // logger.error(e.getMessage(), e);
  128. // return Result.fail(ResultEnum.SERVICE_FAIL.getValue(), "保存异常");
  129. // }
  130. // return Result.success();
  131. // }
  132. //
  133. // @ApiOperation(value = "删除厂商")
  134. // @ApiImplicitParams({@ApiImplicitParam(paramType = "path", name = "id", value = "厂商ID", required = true
  135. // , example = "40288a8b699fc2500169a33b20540000")})
  136. // @DeleteMapping(value = "manufacturer/{id}")
  137. // public Result<Object> del(@PathVariable("id") String id) {
  138. // List<ApplyInfo> appList = applyInfoFacade.getAppListByManufacturerId(id);
  139. // if (null != appList && (!appList.isEmpty())) {
  140. // return Result.fail(ResultEnum.SERVICE_FAIL.getValue(), "厂商已被引用,不可删除!");
  141. // }
  142. // manufacturerInfoFacade.del(id);
  143. // return Result.success("删除成功");
  144. // }
  145. //
  146. // @ApiOperation(value = "获取所有厂商的资料")
  147. // @GetMapping(value = "manufacturer/allManufacturer")
  148. // public Result<List<ManufacturerVo>> getAllManufacturer() {
  149. // List<ManufacturerInfo> manufacturerInfoList = new ArrayList<>();
  150. // BaseSecurityUser user = ContextUtils.getUserInfo();
  151. // //用户范围
  152. // String userMt = mtAuthBusiness.getMtAuth(user.getId(), SysConstants.MT_USER);
  153. // //所有应用
  154. // List<ApplyInfo> applyInfoList = applyInfoFacade.getAllList();
  155. // //范围内加过的厂商
  156. // Set<String> menuSet = new HashSet<>();
  157. // Map<String, OrgTreeNode> allTreeMap = orgInfoFacade.getAllOrgTreeNode();
  158. // for (ApplyInfo applyInfo : applyInfoList) {
  159. // OrgTreeNode node = allTreeMap.get(applyInfo.getOrgId());
  160. // if (node != null) {
  161. // logger.info("node getPath路径:{}", node.getPath());
  162. // }
  163. // //应用所属机构在范围内
  164. // if (node != null && OrgInfoUtil.isHaveAuth(node.getValue(), node.getPath(), userMt)) {
  165. // //未添加的厂商
  166. // if (!menuSet.contains(applyInfo.getManufacturerId())) {
  167. // ManufacturerInfo manufacturerInfo = manufacturerInfoFacade.manufacturerInfoDetail(applyInfo.getManufacturerId());
  168. // if (manufacturerInfo == null) {
  169. // continue;
  170. // }
  171. // menuSet.add(manufacturerInfo.getId());
  172. // logger.info("应用: {}", manufacturerInfo);
  173. // manufacturerInfoList.add(manufacturerInfo);
  174. // }
  175. // }
  176. // }
  177. // List<ManufacturerVo> list = new ArrayList<>();
  178. // for (ManufacturerInfo m : manufacturerInfoList) {
  179. // ManufacturerVo manufacturerVo = new ManufacturerVo();
  180. // BeanUtil.copyProperties(m, manufacturerVo);
  181. // list.add(manufacturerVo);
  182. // }
  183. // return Result.success(list);
  184. // }
  185. //
  186. // @ApiOperation(value = "获取所有厂商的下拉框")
  187. // @RequestMapping(value = "/manufacturer/radio")
  188. // @ResponseBody
  189. // public Result<List<CodeRecord>> getRadio() {
  190. // List<ManufacturerInfo> mlist = new ArrayList<>();
  191. // UserInfo userInfo = userInfoFacade.userDetail(ContextUtils.getUserInfo().getId());
  192. // //外部人员只能配置自己所属厂商下的应用
  193. // if (UserTypeEnum.EXTERNAL.getValue().equals(userInfo.getUserType())) {
  194. // ManufacturerInfo manufacturerInfo = manufacturerInfoFacade.manufacturerInfoDetail(userInfo.getCompany());
  195. // mlist.add(manufacturerInfo);
  196. // } else {
  197. // return Result.success(manufacturerInfoFacade.getAllCodeRecord());
  198. // }
  199. // List<CodeRecord> list = new ArrayList<>();
  200. // for (ManufacturerInfo m : mlist) {
  201. // CodeRecord codeRecord = new CodeRecord();
  202. // codeRecord.setValue(m.getId());
  203. // codeRecord.setLabel(m.getManufacturerName());
  204. // list.add(codeRecord);
  205. // }
  206. // return Result.success(list);
  207. // }
  208. //
  209. // private boolean isManufacturerName(String mName) {
  210. // ManufacturerInfo manufacturerInfo = manufacturerInfoFacade.getOneByName(mName);
  211. //
  212. // return manufacturerInfo != null;
  213. // }
  214. //
  215. // /**
  216. // * 验证厂商代码是否已经存在
  217. // *
  218. // * @param code 厂商代码
  219. // * @return true:存在 false:不存在
  220. // */
  221. // private boolean isCodeExist(String code) {
  222. //
  223. // ManufacturerInfo manufacturerInfo = manufacturerInfoFacade.detailByCode(code);
  224. //
  225. // return manufacturerInfo != null;
  226. // }
  227. //}